第二个“测试”行不应该也被替换吗?我将如何编写命令来替换所有“测试”?
$ sed 's/test/toast/' texttest.txt
toast file test file hahahaha 1
toast file test file hahahaha 2
Run Code Online (Sandbox Code Playgroud)
好的,我知道了 …
g 替换正则表达式的所有非重叠匹配项,而不仅仅是第一个匹配项。
$ sed 's/test/toast/g' texttest.txt
toast file toast file hahahaha 1
toast file toast file hahahaha 2
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
375 次 |
最近记录: |