1
我希望有人可以解釋爲什麼SED的地方不工作perl做針對此問題:VS Perl的正則表達式的sed substitue /(FOO |酒吧)/
$ egrep "(foo|bar)=0" /var/tmp/test.txt
This is example output of the test.txt file foo=0
This is another example output of the bar=0 test.txt file
$ sed -ir 's/(foo|bar)=0//g' /var/tmp/test.txt
$ egrep "(foo|bar)=0" /var/tmp/test.txt
This is example output of the test.txt file foo=0
This is another example output of the bar=0 test.txt file
$
用Perl試圖替代的作品:
$ egrep "(foo|bar)=0" /var/tmp/test.txt
This is example output of the test.txt file foo=0
This is another example output of the bar=0 test.txt file
$ perl -ne 's/(foo|bar)=0//g;print;' -i /var/tmp/test.txt
$ egrep "(foo|bar)=0" /var/tmp/test.txt
$
有沒有辦法讓sed完成perl在這裏的工作?非常感謝你!
同'perl的-in -e」。 ..「,例如。 – ThisSuitIsBlackNot