Friday, January 22, 2010

強大的awk

透過awk找出系統帳號中誰的預設shell是屬於bash,並統計有幾筆。
[root@centos bin]# awk -F: 'BEGIN{count=0};/bash/{count++}/bash/{print $1};END{print "TOTAL="count}' /etc/passwd
root
u1
u2
law
mysql
TOTAL=5

No comments: