我无法在命令行上执行最基本的 sed 命令

Nil*_*zor 5 command-line sed

我觉得自己像个新手。为什么这不起作用?

$ 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/" textfileand sed '/foo/bar/' textfile,它们都会产生相同的错误。

通过 bash 使用 ubuntu 8.04 和 GNU sed 4.1.5 版。

jip*_*pie 8

试试这个:sed 's/foo/bar/' textfile

  • 语句周围的引号是很好的做法
  • s为替代。这是您要执行的命令。foo是搜索词bar替换。

sed 网上有很多资料。例如:http : //www.catonmat.net/blog/sed-one-liners-explained-part-one/