首页 > 代码库 > shell脚本,awk数组之如何处理多个文件。

shell脚本,awk数组之如何处理多个文件。

[root@localhost awk]# seq 10|xargs -n 2 > file[root@localhost awk]# seq 10  -1 1|xargs -n 2 > file1[root@localhost awk]# cat file1 23 45 67 89 10[root@localhost awk]# cat file110 98 76 54 32 1[root@localhost awk]# cat file |awk {print $1}13579[root@localhost awk]# cat file1 |awk {print $2}97531[root@localhost awk]# cat file |awk {print $1}>file3[root@localhost awk]# cat file1 |awk {print $2}>file4[root@localhost awk]# paste file3 file41    93    75    57    39    1[root@localhost awk]# paste file3 file4|tr "\t" " "1 93 75 57 39 1[root@localhost awk]# paste file3 file4|tr "\t" " ">file5[root@localhost awk]# cat file51 93 75 57 39 1[root@localhost awk]# awk 1 file1 23 45 67 89 10[root@localhost awk]# awk 1 file110 98 76 54 32 1[root@localhost awk]# awk 1 file1 file110 98 76 54 32 110 98 76 54 32 1[root@localhost awk]# awk {print NR} file file112345678910[root@localhost awk]# awk {print NR,FNR} file file11 12 23 34 45 56 17 28 39 410 5[root@localhost awk]# [root@localhost awk]# awk NR==FNR{a[NR]=$1}NR!=FNR{print a[FNR],$2} file file11 93 75 57 39 1[root@localhost awk]# 

 

shell脚本,awk数组之如何处理多个文件。