I have a very large csv file. How would you remove the very last ,
with sed (or similar) ?
...
[11911,0,"BUILDER","2014-10-15","BUILDER",0,0],
[11912,0,"BUILDER","2014-10-15","BUILDER",0,0],
[11913,0,"BUILDER","2014-10-15","BUILDER",0,0],
]
Desired output
...
[11911,0,"BUILDER","2014-10-15","BUILDER",0,0],
[11912,0,"BUILDER","2014-10-15","BUILDER",0,0],
[11913,0,"BUILDER","2014-10-15","BUILDER",0,0]
]
The following sed command will delete the last occurrence per line, but I want per file.
sed -e 's/,$//' foo.csv
Nor does this work
sed '$s/,//' foo.csv
Best Answer
Using
awk
If the comma is always at the end of the second to last line:
Using
awk
andbash
Using
sed
For OSX and other BSD platforms, try:
Using
bash