我有以下 CSV 文件:
"test","test2","test
3 and some other
data"
"test4","test5","test6 and some other
data"
我想用字符替换所有换行符(windows或unix样式)\n
,所以我会得到:
"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
}'