[H-GEN] Converting csv file to tab delimited text file
Ted Percival
ted at midg3t.net
Wed Jun 7 00:14:30 EDT 2006
Kelvin Heng wrote:
> I am writing scripts using bash shell in cygwin. Right now, I have a set
> of raw data that is daily exported from a server into a csv format. My
> script can only process a Tab Delimited text file, so I have to open the
> file in excel and save it as Tab Delimited text file. Anyone has any
> alternative to automate this process? Please comments.
I've never really had to deal with CSV or tab delimited files, but
either of the following might be close to what you're after.
Given the file 'file' with the following contents:
a,b,c
d,e,f
To replace the commas with tabs (presumably that's all you need), try:
tr , '\t' < file
or:
sed -e 's/,/\t/g' file
You can use shell redirection to output to a file, or the non-standard
'-i' flag for sed to do in-place editing.
-Ted
More information about the General
mailing list