SED 替换功能:
1 sed -i ‘s#h#i#g‘ readme.txt
2 s 替换
g 全局替换
-i 修改文件
-n 取消默认输出
p 打印
[[email protected] cy]# ifconfig eth0| sed -n 2p
inet addr:172.17.0.17 Bcast:172.17.15.255 Mask:255.255.240.0
[[email protected] cy]# ifconfig eth0| sed -n "2p"
inet addr:172.17.0.17 Bcast:172.17.15.255 Mask:255.255.240.0
3 awk -F "[ :]+" ‘{print $3,$5,$7}‘ 3.txt |awk ‘{print $1}‘
172.17.0.17
2 [[email protected] cy]# ifconfig eth0 |grep "inet addr" |sed s#‘^.*r:##g‘|sed ‘s#Bc.*$##g‘
时间: 2024-10-26 11:27:25