我希望有人可以解释为什么sed在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
$ 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
$
Run Code Online (Sandbox Code Playgroud)
尝试用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 …Run Code Online (Sandbox Code Playgroud)