[root@oldboy awk]# awk 'BEGIN{RS="(:|\n)"} {print $0}' /etc/passwd |sort|uniq -c|sort -r 26 x 20 /sbin/nologin 6 0 6 4 /sbin 4 / 3 /bin/bash 2 uucp 2 sync 2 shutdown 2 root 2 operator 2 mail 2 lp 2 halt 2 gopher 2 games 2 daemon 2 bin 2 adm 2 99 2 89 2 81 2 74 2 72 2 7 2 69 2 68 2 501 2 500 2 4 2 38 2 2 2 173 2 14 2 12 2 1 2 /root 1 virtual console memory owner 1 vcsa 1 tcpdump 1 sshd 1 saslauth 1 postfix 1 oldboy1 1 oldboy 1 ntp 1 nobody 1 haldaemon 1 ftp 1 dbus 1 abrt 1 System message bus 1 Saslauthd user 1 Privilege-separated SSH 1 Nobody 1 HAL daemon 1 FTP User 1 8 1 76 1 6 1 50 1 5 1 499 1 30 1 3 1 13 1 11 1 100 1 10 1 /var/spool/uucp 1 /var/spool/postfix 1 /var/spool/mail 1 /var/spool/lpd 1 /var/gopher 1 /var/ftp 1 /var/empty/sshd 1 /var/empty/saslauth 1 /var/adm 1 /usr/games 1 /sbin/shutdown 1 /sbin/halt 1 /home/oldboy1 1 /home/oldboy 1 /etc/ntp 1 /etc/abrt 1 /dev 1 /bin/sync 1 /bin
awk 'BEGIN{RS="(:|\n)"} {print $0}' /etc/passwd |sort|uniq -c|sort -r
'BEGIN{RS="(:|\n)"}利用BEGIN的分割,每一个单词分成一个记录 ,分隔符为:
然后print整行,通过管道排序(sort)然后统计(uniq -c)在从高到低排序(sort -r)