Content #
如果需要在单行中执行多条命令,可以用花括号将其组合在一起,sed编辑器会执行匹配地址中列出的所有命令:
$ sed '2{
> s/fox/toad/
> s/dog/cat/
> }' data1.txt
The quick brown fox jumps over the lazy dog.
The quick brown toad jumps over the lazy cat.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
$
这两条命令都会应用于该地址。当然,也可以在一组命令前指定行区间:
$ sed '3,${
> s/brown/green/
> s/fox/toad/
> s/lazy/sleeping/
> }' data1.txt
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick green toad jumps over the sleeping dog.
The quick green toad jumps over the sleeping dog.
From #
Linux命令行与shell脚本编程大全