Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用bash在linux中编辑文件_Bash - Fatal编程技术网

使用bash在linux中编辑文件

使用bash在linux中编辑文件,bash,Bash,假设我在文本文件中有以下内容: ................. value1= "2000"; justAtext= "hello Text" .................................. 我的问题是,是否有linux cmd允许我搜索文件,例如“value” 然后用其他类似的东西替换整个线路: ................. changedText= "Hello"; justAtext= &quo

假设我在文本文件中有以下内容:

.................
value1= "2000";
justAtext= "hello Text" 
..................................
我的问题是,是否有linux cmd允许我搜索文件,例如“value” 然后用其他类似的东西替换整个线路:

.................
changedText= "Hello";
justAtext= "hello Text" 
..................................
.................
changedText= "Hello";
justAtext= "hello Text" 
..................................

提前感谢您的任何提示

是的,有几种方法。最快的国际海事组织:


输入

.................
value1= "2000";
justAtext= "hello Text" 
..................................
假设此文本位于名为foo.txt的文件中


精化

sed-iE的/value1=.*/changedText=“Hello”/g'foo.txt

  • -i
    ->替换同一文件上的内容(省略此选项,输出将打印在标准输出上)
  • -E
    ->使用正则表达式

输出

.................
value1= "2000";
justAtext= "hello Text" 
..................................