N: 读取新的输入行,并将它添加到模式空间的现有内容之后
n: 输出模式空间的内容,然后读取新的行
cat mulmodel
=>
Consult Section 3.1 in the Owner and Operator
Guide for a description of the tape drives
available on your system
sed '/Operator$/{N;s/Owner and Operator/nGuide/Installation Guide}'
=>
Consult Section 3.1 in the Installation Guide for a description of the tape drives
available on your system
-----------------------------------------------------------------
D: 删除模式空间的中直到第一个嵌入的换行符的这部分内容,返回脚本的顶端,将脚本应用于模式空间的剩余内容
d: 删除模式空间的内容并导致读入新的输入行,从而在脚本的顶端重新使用编辑方法
----------------------------------------------------------------
P: 输出多行模式空间的第一部分到第一个嵌入的换行符为止
Print命令经常出现在Next命令之后和Delete命令之前,这三个命令能建立一个输入/输出循环,用来维护两行的模式空间。但是一次只输入第一行。
cat print
=>
Here are examples of the UNIX
System. Where UNIX
System appears, it should be the UNIX
Operating System
sed '/UNIX$/{N;//nSystem/{s// Operation &/;P;D}}' print
#如果发现UNIX/nSystem=》UNIX Operation/nSystem
=>
Here are examples of the UNIX Operation
System. Where UNIX Operation
System appears, it should be the UNIX
Operating System