小编lib*_*teh的帖子

Perl vs Sed regex substitue /(foo | bar)/

我希望有人可以解释为什么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)

regex perl sed

1
推荐指数
1
解决办法
157
查看次数

标签 统计

perl ×1

regex ×1

sed ×1