Wednesday, 18 September 2013

Awk split file give incomplete lines

Awk split file give incomplete lines

my file is a csv file with comma delimited fields.
I tried to split the file into multiple files by first field. I did the
following.
cat myfile.csv | awk -F',' '{print $0 > "Mydata"$1".csv"}'
It does split the file, but the file is corrupted, the last line of each
file is not complete. The breaking position seems random. Anyone has the
same problem?

No comments:

Post a Comment