Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I have some data which is comma delimited. How do I change it to be tab delimited?
I tried sed 's/,/\t/g' but it just replaced the commas with a t.

Hi:
One way is to actually embed the special tab character in the sed string. In vi, this is done by pressing the control-v followed by the tab character:
sed 's/,/ /g' data.file
Obviously, you can NOT cut-and-paste such a line. Instead, consider embedding the octal value of the tab character, 011, inside the sed command:
sed 's/,/'"$(printf '\011')"'/g' data.file
Yes, the embedded quotes are important. The echo command works as well, but I prefer printf for portability:
sed 's/,/'"$(echo '\011')"'/g' data.file
Regards,
Nails

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |