- 打印:
sed -n '/yes/p' test.txt #打印test.txt文件中包含yes的行
2. 大小定转换:
sed 'y/abcdef/ABCDEF/' test.txt
3. 更改:
sed '/BOOTPROTO/c BOOTPROTO=dhcp' test.txt
4. 替换:
sed '/yes/s//no/g' test.txt
5. 合并文件:
sed '$r test.sh' test.txt
6. 合并行:
sed -n '/a/N;L' test.txt
7. 模式空间:
h|H 加入到模式空间
g|G 从模式空间中取出
x 交换模式空间和保持空间中的内容