在bash的sed命令中使用感叹号

时间:2018-08-02 18:37:13

标签: regex bash sed

我有一个这样的文件,我想用sed来处理。

// file.js
return foo.quux();

运行以下内容:

$ sed -i "s/foo\.(?!bar|baz)/qux\./g" file.js

预期要替换的文件,例如:

// file.js
return qux.quux();

但是bash不断告诉我:

bash: !bar: event not found

重写为:

$ sed -i "s/foo\.(?'!'bar|baz)/qux\./g" file.js

但是bash仍要出于自己的目的使用感叹号:

bash: !: event not found

在没有sed参与的情况下,有人对如何制作bash的排除有任何提示吗?

0 个答案:

没有答案