去除空格
cat a.txt | sed 's/ //g'
显示某一行下面的所有内容
源文件
br-73908aa622e3: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:c5:14:e8:db txqueuelen 0 (Ethernet)
RX packets 159340 bytes 12148863 (11.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 110088 bytes 15332872 (14.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
显示docker0后面的的所有行数
ifconfig |sed -n '/docker0/,$p'
[root@aliyun ~]# ifconfig |sed -n '/docker0/,$p'
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:c5:14:e8:db txqueuelen 0 (Ethernet)
RX packets 159340 bytes 12148863 (11.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 110088 bytes 15332872 (14.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@aliyun ~]#
显示第四行内容
ifconfig |sed -n '4p' |awk '{print $5}'
awk叠加
lag=bash /wls/apache/kafka/kafka/bin/kafka-consumer-groups.sh --bootstrap-server 196.168.1.1:9876--describe --group $group | grep -v 'LAG' | awk -F ' ' '{print $5}' | awk '{sum+=$1} END {if(sum>100000) print sum}'