分类: LINUX
2008-02-25 23:18:08
[root@TestAs4 hlj]# more hljerro_cod.txt
5 WAP手机报:联通手机报超值版
3 彩信手机报:联通手机报超值版
[root@TestAs4 hlj]# head 5 hljerro0225.txt
head: 无法打开 ‘5’ 来读取数据: 没有那个文件或目录
==> hljerro0225.txt <==
8613304537*** WAP手机报:联通手机报超值版
8613304678*** WAP手机报:联通手机报超值版
8613304693*** WAP手机报:联通手机报超值版
[root@TestAs4 hlj]# awk 'NR==FNR{a[$2]=$1}NR>FNR&&a[b=$2]{print $1,a[b]}' hljerro_cod.txt hljerro0225.txt |more
8613304537*** 5
8613304678*** 5
8613304693*** 5
==================================================================================
[root@TestAs4 gd]# more mdn.sh
#!/bin/bash
for fname in `ls *.sub`
do
awk '{print "'$fname'""|"$0}' $fname >>cwm
done
[root@TestAs4 gdmdn]# more cwm.txt
34301_20080311000001.sub 9105138265 13025XXX101 13025XXX101
34301_20080311000001.sub 9105138265 13047XXX361 13047XXX361
34301_20080311000001.sub 9105138265 13049XXX156 13049XXX156
34301_20080311000001.sub 9105138265 13112XXX635 13112XXX635
34301_20080311000001.sub 9105138265 13129XXX080 13129XXX080
[root@TestAs4 gdmdn]# more new.txt
13006XXX000 东莞
13006XXX009 东莞
13006XXX008 东莞
13006XXX525 东莞
13006XXX293 东莞
13006XXX518 东莞
1129 dos2unix *.txt
1132 awk 'NR==FNR{a[$1]=$2}NR>FNR{ if($4 in a) print $0,a[$4]}' new.txt cwm.txt >moli
1136 sed 's/.sub//g' moli >moli.txt
1147 awk '{fn1=$1;fn2=$5;{print $2"|"$3"|"$4>>fn1"_"fn2".sub"}}' moli.txt