this is to test that was for test
我想在以“this”开头的行中替换“test”.
$sed '/^this/ s/test/something/' inputfile this is to something that was for test
这将用以此为开头的行替换单词test.
如果要替换匹配行上的所有测试实例,请为sed提供g选项:
sed '/^this/ s/test/something/g' inputfile