首页 > 代码库 > awk

awk

awk的使用:

    移动文件:ls -lrt|awk ‘{ if( substr($8,6,8) == ‘20111029‘ && substr($8,26,3) == ‘unl‘ ) print "mv "$8" /home/etl/data/interface;" }‘|ksh

    求和: awk ‘{sum+=$1}END{print sum}‘

     删除文件:ls -lrt|awk ‘{ if( substr($8,4,8) == ‘20111029‘ ) print "rm "$8" /home/etl/data/interface;" }‘|ksh

                          find ./ -name "*20111113*" | awk ‘{print "rm " $1}‘ | ksh

     查找文件:find . -name "*sms20111201*.unl" |xargs awk -F‘|‘ ‘{if ($39 == ‘-1‘) print FILENAME"|"$0}‘

awk