Linux awk 文件抽取命令
时间:2010-10-08 来源:langhu193867
抽取文件的一些SEHLL 脚本代码 :
ls /predeal01/new_pre/gz?/* |awk ' FS="/" { print $NF}' |while read fname
do
echo "/predeal01/wangfx/sms/sms/*${fname}"
echo "/bill01/predeal_out/gsm/y*D22*${fname} "
cat /predeal01/wangfx/sms/sms/*${fname}* |awk ' FS="," {
print '${fname}'"\t"$2"\t"$3"\t"$4"\t"$7"\t"$8"\t"$22"\t"$27
}'|sort>"/huangqh/predeal/old.txt"
cat /bill01/sm_bill/bak/sms/y*${fname} |awk '
{ print '${fname}'"\t"print substr($0,34,2)"\t"substr($0,37,11)"\t"substr($0,79,3)"\t"
substr($0,58,11)"\t"substr($0,82,3)"\t"substr($0,108,14)"\t"substr($0,122,14)} }
'|tr -d ' '|sort>"/huangqh/predeal/new/${fname}"
diff /huangqh/predeal/old/${fname} /huangqh/predeal/new/${fname}
> /huangqh/predeal/out/${fname}.diff
iff done
do
echo "/predeal01/wangfx/sms/sms/*${fname}"
echo "/bill01/predeal_out/gsm/y*D22*${fname} "
cat /predeal01/wangfx/sms/sms/*${fname}* |awk ' FS="," {
print '${fname}'"\t"$2"\t"$3"\t"$4"\t"$7"\t"$8"\t"$22"\t"$27
}'|sort>"/huangqh/predeal/old.txt"
cat /bill01/sm_bill/bak/sms/y*${fname} |awk '
{ print '${fname}'"\t"print substr($0,34,2)"\t"substr($0,37,11)"\t"substr($0,79,3)"\t"
substr($0,58,11)"\t"substr($0,82,3)"\t"substr($0,108,14)"\t"substr($0,122,14)} }
'|tr -d ' '|sort>"/huangqh/predeal/new/${fname}"
diff /huangqh/predeal/old/${fname} /huangqh/predeal/new/${fname}
> /huangqh/predeal/out/${fname}.diff
iff done
相关阅读 更多 +