替换文本中的字符串
sed ‘s/book/books/‘ file
匹配file文件中每一行的第一个book替换为books
sed -i ‘s/book/books/g’ file
全面替换
sed ‘s/book/books/g’ file
从第n处开始替换
echo sksksksksksk | sed ‘s/sk/SK/2g’
skSKSKSKSKSK
删除空白行
sed ‘/^$/d’ file
已匹配字符串标记&
sed ‘s/^192.168.0.1/&localhost/‘ file
192.168.0.1localhost
选定行的范围: , (逗号)
所有在模板test和check所确定的范围内的行都被打印:
sed -n ‘/test/,/check/p’ file
