如何从文件的最后一行删除逗号?这是文件:
# cat ox_data_archive_r_20120727.json
{"name": "secondary_ua","type":"STRING"},
{"name": "request_ip","type":"STRING"},
{"name": "cb","type":"STRING"},
以下将从所有 3 行中删除逗号。
# sed 's/,$/\ /' ox_data_archive_r_20120727.json
{"name": "secondary_ua","type":"STRING"}
{"name": "request_ip","type":"STRING"}
{"name": "cb","type":"STRING"}
我只需要删除最后一个逗号。所以输出应该看起来像这样......
# cat newfile.json
{"name": "secondary_ua","type":"STRING"},
{"name": "request_ip","type":"STRING"},
{"name": "cb","type":"STRING"}