Skip to content
Home ยป How to Convert the Comma(s) into the Space(s) on a Linux File?

How to Convert the Comma(s) into the Space(s) on a Linux File?

  • by

The previous article explained how to convert spaces into commas in a Linux file. This article will explain how to convert a comma into a space on Linux.

 

Problem

How to convert the comma(s) into the space(s) on a Linux file?

 

Solution

For example, you have a test.txt file as shown below:

convert the comma(s) into the space(s)
The test.txt file

 

So that the file is a comma sign into a space, then use the command below:

cat test.txt | tr ',' ' '

 

So the results will be like the picture below:

convert the comma(s) into the space(s)
Convert the comma to a space using the tr command

 

You can also use the command below to convert the comma(s) to the space(s):

Convert the comma to a space using the sed command

 

Note

If your file uses other symbols besides the comma symbol, for example, the symbol of the colon(:), just change the comma into a colon on the two commands above. For example, if you use the tr command, then use the command below:

cat test.txt | tr ':' ' '

 

And the file should be as shown below:

Change the colon(s) to a space

 

References

stackoverflow.com
phoenixnap.com

image_pdfimage_print
Visited 44 times, 1 visit(s) today
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *