三剑客-sed
【sed命令】
sed 's~\(include http_cc.*\)~#\1~' /usr/local/nginx/conf/http_facadehost/default.conf 只打印
sed -i 's~\(include http_cc.*\)~#\1~' /usr/local/nginx/conf/http_facadehost/default.conf
#追加
sed -i '$a\10.32.61.79 sbapi.opm11.com' /etc/hosts
#清空空格行
sed -i '/^ *$/d' /etc/hosts
子串匹配标记\1
匹配给定样式的其中一部分:
echo this is digit 7 in a number | sed 's/digit \([0-9]\)/\1/'
this is 7 in a number

浙公网安备 33010602011771号