我有以下CSV文件:bash的换行符替换成引号
"test","test2","test
3 and some other
data"
"test4","test5","test6 and some other
data"
我想通过字符\n
全部更换为新行(Windows或UNIX风格),所以我将获得:
"test","test2","test\n3 and some other\n\ndata"
"test4","test5","test6 and some other\n\n\ndata"
我试着awk
但没有成功:
cat myFile.csv | awk -F \" -v OFS=\" '{
for (i=0; i<NF; i++) {
gsub("\\n", "\\\\n", $i)
}
print
}'
您可以通过替换做到这一点'\([^“] \)\ n \(。\)'用'\ 1 \\ n \ 2'(例如使用Perl) –