How to remove a comma from the last line of a file? Here is the file:
# cat ox_data_archive_r_20120727.json {"name": "secondary_ua","type":"STRING"}, {"name": "request_ip","type":"STRING"}, {"name": "cb","type":"STRING"},
The following will remove the comma from all three lines.
# sed 's/,$/\ /' ox_data_archive_r_20120727.json {"name": "secondary_ua","type":"STRING"} {"name": "request_ip","type":"STRING"} {"name": "cb","type":"STRING"}
I need to remove only the last comma. Thus, the result should look something like this:
# cat newfile.json {"name": "secondary_ua","type":"STRING"}, {"name": "request_ip","type":"STRING"}, {"name": "cb","type":"STRING"}
source share