说我有以下文本文件:
.................
value1= "2000";
justAtext= "hello Text"
..................................
我的问题是,是否有任何 linux cmd 可以让我搜索文件,例如“值”,而不是用其他类似的东西替换整行:
.................
changedText= "Hello";
justAtext= "hello Text"
..................................
提前感谢您的任何提示!
是的,有几种方法可以做到这一点。最快的国际海事组织:
输入
.................
value1= "2000";
justAtext= "hello Text"
..................................
假设此文本位于名为 foo.txt 的文件中
细化
sed -iE 's/value1=.*/changedText= "Hello";/g' foo.txt
-i
-> 替换同一文件上的内容(省略此选项,输出将打印在标准输出上)-E
-> 使用正则表达式输出
.................
changedText= "Hello";
justAtext= "hello Text"
..................................
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句