sed 使用笔记
sed
替换
oldfile文件中的每行第一个find为replace,保存内容到newfile中sed 's/find/replace/' <oldfile >newfile替换
oldfile文件中的每一个<space>find为replace,保存内容到newfile中sed 's/ find/replace/g' <oldfile >newfile替换
filename文件中的每一个find为replacesed -i 's/find/replace/g' filename替换
filename文件中的包含Replace文字的每一行中的the为THEsed -i '/Replace/s/the/THE/g' filename删除
filename文件中的包含Replace文字的每一行sed -i '/Replace/d' filename不使用
-i则打印内容运行多条命令
sed -i '...;...' filenamesed -i -e '...' -e '...' filename
\/转义/或使用s#find#replace#g,s|find|replace|g,.打印出包含
usr的每一行:sed '/user/p'删除
redacted:sed "s/redacted//g filename删除空行:
sed "/^$/d" filename