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