Tuesday, August 19, 2008
Given a file abc.txt with:
1
2
3
4
5
6
7
Here's a quick one liner to convert that to a line of CSV:
perl -e 'chomp(@data=<STDIN>);print join(",",@data),"\n";' < abc.txt
Incidentally, I tested this with a quick bash counterpart:
tr "\n" "," < abc.txt | sed 's/,$//'
After timing them both a few times, the results were pretty much the same.
0 Comments:
Post a Comment