我觉得自己像个新手。为什么这不起作用?
$ echo foobar > textfile
$ sed /foo/bar/ textfile
sed: can't find label for jump to `ar/'
Run Code Online (Sandbox Code Playgroud)
我也试过sed "/foo/bar/" textfile
and sed '/foo/bar/' textfile
,它们都会产生相同的错误。
通过 bash 使用 ubuntu 8.04 和 GNU sed 4.1.5 版。
试试这个:sed 's/foo/bar/' textfile
。
s
为替代。这是您要执行的命令。foo
是搜索词bar
替换。sed 网上有很多资料。例如:http : //www.catonmat.net/blog/sed-one-liners-explained-part-one/