sed 使用实例
1. 增加
增加一行:
行前增加:sed '1i bind 127.0.0.1' redis_*/*conf
行后增加:sed '1a bind 127.0.0.1' redis_*/*conf
增加多行
sed '1a bind 127.0.0.1\
port 6379' redis_*/*conf
2.替换
整行替换
nl /etc/passwd | sed '2,5c thesentensetochange'
nl /etc/passwd | sed 's/1/2/g'
sed -i "s/\"workerCount\": 1,/\"workerCount\": 0,/g" `grep '\"workerCount\":
1,' -rl --include="*.json" /data/app/`
3.删除
nl /etc/passwd | sed '2,5d'