,"some values1","some values2",Not Processed,0,
有什么方法可以替换上面的模式,而不管以下行中的值1或值2中的值是什么,
,,,Not Processed,0,
此字符串只是我拥有的大文件的一部分。
答案 0 :(得分:0)
这解决了我认为的问题:
test_data() {
cat <<EOF
,"val1,val2...","val1,val2,val3..",Not Processed,0,
,"val1,val2..","",Not Processed,0,
,"","val1,val2,val3....",Not Processed,0,
EOF
}
test_data | sed -e 's/\(.*\),"[^"]*","[^"]*",\(Not Processed,0,\)\(.*\)/\1,,,\2\3/g'
输出:
▶ bash data.sh
,,,Not Processed,0,
,,,Not Processed,0,
,,,Not Processed,0,