how to convert comma delimited file to tab separator

Hi all,

How can i convert comma delimited .csv file to tab separate using sed command or script.

Thanks,
Krupa

Hi,
Try this,

sed 's/\,/\t/g' file >outfile
awk '{gsub(/\,/,"press tab");print;}' file >outfile

if you dont want use the new file to store the result and update in same file. just use the below cmd

awk '{gsub(/\,/,"press tab");a[NR]=$0;}END{for (i=1;i<=NR;i++){print a >FILENAME;}}' file

press tab button in gsub replace str.
Cheers,
Ranga:-)

cat oldfile.txt | tr '[,]' '[\t]' > newfile.txt

Why the square brackets? If those are intended to be single character bracket expressions, tr does not support that syntax. Well, I should say, POSIX tr. Perhaps that is an older dialect? In modern implementations, that simply replaces [ with itself and ] with itself, a couple of no-ops, in addition to comma with tab.

Or am I overlooking something?

Regards,
Alister

Obviously harmless if the square brackets are both sides. I had never noticed that unescaped were not treated as special characters in some syntaxes of Posix "tr".
Strangely I don't usually put for single characters but it ended up like that after simplifying the command.

The "tr" command line modifies the default translation table for that locale. There is no additional processing when the translate itself takes place.