awk

2019-03-14  本文已影响0人  泠泉
20190314-065245.jpg

awk经过改进生成的新的版本nawk,gawk. linux下是gawk



sed '/Error/p' fresh.log | awk '{print $1}'
awk '/Error/{print $1}' fresh.log


awk -F ':' '$1~/^m.*/{print $1}' passwd
awk -F ':' '$3>100{print $1,$3}' passwd
awk -F ':' '$3==100{print $1,$3}' passwd
awk -F ':' '$3!=100{print $1,$3}' passwd


# 打印ip
ipconfig | sed -n "/IPv4.*/p" | awk -F ":" "{print $2}"
ipconfig | awk -F ":" "/IPv4/{print $2}"

awk -F ':' 'BEGIN{print "Line Col User"}{print NR,NF,$1}END{print"----"FILENAME"---"}' passwd

ls -l | awk 'BEGIN{size=0}{size+=$5}END{print " size is " size}'

awk -F ':' 'BEGIN{count=0}$1!~/^$/{count++}END{print " count = "count}' passwd

awk -F ':' 'BEGIN{count=0}$1!~/^$/{count++}END{print " count= "count}' passwd

awk -F ':' 'BEGIN{count=0}{if ($3>100) name[count++]=$1}END{for (I=0;i<count;i++) print I,name[I]}' passed

netstat -anp | awk '$6~/CONNECT|LISTEN/{sum{$6}++}END{for (i in sum) print i,sum[i]}'

上一篇下一篇

猜你喜欢

热点阅读