我有一个CSV文件,我想删除全部换行符(LF或\ n),它们都在双引号之间。
您能否提供一个Unix脚本来执行上述任务。我在下面给出了输入和预期输出。
输入:
没有,状态,日期
1,“成功
错误”,1 /二千零十八分之十五
2,“成功
错误
NA”,2 /二千零十八分之十五
3,“成功
错误”,3 /二千零十八分之十五
预期输出:
没有,状态,日期
1,“成功错误”,1/15/2018
2,“成功错误NA”,2/15/2018
3,“成功错误”,3/15/2018
答案 0 :(得分:0)
我无法为您编写所有内容,因为我不确定您的系统以及在其上运行的bash版本。但是这里有一些你可能想要考虑的建议。
https://www.unix.com/shell-programming-and-scripting/31021-removing-line-breaks-shell-variable.html
https://www.unix.com/shell-programming-and-scripting/19484-remove-line-feeds.html
How to remove carriage return from a string in Bash
https://unix.stackexchange.com/questions/57124/remove-newline-from-unix-variable
Remove line breaks in Bourne Shell from variable
https://unix.stackexchange.com/questions/254644/how-do-i-remove-newline-character-at-the-end-of-file
https://serverfault.com/questions/391360/remove-line-break-using-awk