Perl one-liner for replacing tabs with commas


This will replace all the tabs in tabbedfile.txt with commas.

perl -pi -e 's/\t/,/g' tabbedfile.txt

The -i means modify in place meaning the original file will be modified with no backup. If you want a backup copy of the original file to be created, use -i.bak instead of just -i, like so:

perl -pi.bak -e 's/\t/,/g' tabbedfile.txt

If you want to preserve the tabs in the original file, cat it to the perl and redirect the output to a new file, like so:

cat tabbedfile.txt |perl -pi -e 's/\t/,/g' >commafile.txt

08/30/2006