源文件格式
1 2 3 4 5 6
要的文本格式
a:1 b:2 c:3 d:4 e:5 f:6
具体实现看代码吧
多说无益= =root@lp:~/pwb/tmp/awk# echo -e "\n"{a..i} > a
root@lp:~/pwb/tmp/awk# echo -e "\n"{1..9} > b
root@lp:~/pwb/tmp/awk# paste b a|sed 1d > c
root@lp:~/pwb/tmp/awk# cat c
1 a
2 b
3 c
4 d
5 e
6 f
7 g
8 h
9 i
root@lp:~/pwb/tmp/awk# cat file
1 2 3 4 5 6
root@lp:~/pwb/tmp/awk# awk 'NR==FNR{a[$1]=$2}NR!=FNR{for(i=1;i<=NF;i++){if(a[$i])printf a[$i]":"$i" "}print xxoo}' c file
a:1 b:2 c:3 d:4 e:5 f:6