我有以下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) –