$ cat tmp.txt
hello world
hello linux
hello perl
good perler
best linuxer
strong unixer
weak windower
perl -F'\W' -ane 'END {print $x} $x += @F' tmp.txt
14
$ cat tmp2.txt
abc:123:kab
321:aed:net
$ perl -F':' -ane 'END {print $x} $x += @F' tmp2.txt
6
$ perl -F':' -ane 'chomp($F[6]); $s{$F[6]}++;' -e 'END { print "$_ : $s{$_}\n" for keys %s }' /etc/passwd
/bin/sh : 1
/sbin/halt : 1
/bin/sync : 1
/sbin/nologin : 40
/sbin/shutdown : 1
/bin/bash : 3
/bin/false : 1
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |