见:Perl One-liners by Jeff Bay
#BEGIN和END块
ls -lAF | perl -ne 'next if /^d/; $sum += (split)[4]; END{ print "$sum\n" }'
ls -lAF | perl -ne 'BEGIN{$sum=1024} next if /^d/; $sum += (split)[4]; END{ print "$sum\n" }'
#test.txt中第一列中的最大值:
perl -ne "$i = (split)[0];$max=$i if($max<$i); END {print $max;}" < test.txt
没有评论:
发表评论