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
尝试参与的情况下制作排除的任何提示?
解决方案
推荐阅读
- python - Pandas 数据框 groupby value_counts
- nstableview - 使用 NSPasteboard 重新排序和移动 NSTableView 行
- html - 访问嵌入在模板 Angular 中的组件
- vue.js - VueX:如何加载外键的数据(微服务架构)
- python - 列表格式的文本文件到列表中
- sql - Sql 查询返回有关花费最多的客户的信息
- java - JavaFX:tableView 保持为空(“IllegalStateException:无法从不可读的属性中读取”)
- sql - 选择 WHERE 子句排除的“空”记录
- c++ - 将 GCC 9.3.0 降级到 7 以用于 openpose 后,cuda_compile_1_generated_batch_norm_layer.cu.o.Release.cmake 出现 CMake 错误
- javascript - 查找 tab li 是否有活动类