shell脚本,awk数组之如何处理多个文件。
Posted 王月波
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell脚本,awk数组之如何处理多个文件。相关的知识,希望对你有一定的参考价值。
[[email protected] awk]# seq 10|xargs -n 2 > file [[email protected] awk]# seq 10 -1 1|xargs -n 2 > file1 [[email protected] awk]# cat file 1 2 3 4 5 6 7 8 9 10 [[email protected] awk]# cat file1 10 9 8 7 6 5 4 3 2 1 [[email protected] awk]# cat file |awk ‘{print $1}‘ 1 3 5 7 9 [[email protected] awk]# cat file1 |awk ‘{print $2}‘ 9 7 5 3 1 [[email protected] awk]# cat file |awk ‘{print $1}‘>file3 [[email protected] awk]# cat file1 |awk ‘{print $2}‘>file4 [[email protected] awk]# paste file3 file4 1 9 3 7 5 5 7 3 9 1 [[email protected] awk]# paste file3 file4|tr "\t" " " 1 9 3 7 5 5 7 3 9 1 [[email protected] awk]# paste file3 file4|tr "\t" " ">file5 [[email protected] awk]# cat file5 1 9 3 7 5 5 7 3 9 1 [[email protected] awk]# awk ‘1‘ file 1 2 3 4 5 6 7 8 9 10 [[email protected] awk]# awk ‘1‘ file1 10 9 8 7 6 5 4 3 2 1 [[email protected] awk]# awk ‘1‘ file1 file1 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1 [[email protected] awk]# awk ‘{print NR}‘ file file1 1 2 3 4 5 6 7 8 9 10 [[email protected] awk]# awk ‘{print NR,FNR}‘ file file1 1 1 2 2 3 3 4 4 5 5 6 1 7 2 8 3 9 4 10 5 [[email protected] awk]# [[email protected] awk]# awk ‘NR==FNR{a[NR]=$1}NR!=FNR{print a[FNR],$2}‘ file file1 1 9 3 7 5 5 7 3 9 1 [[email protected] awk]#
以上是关于shell脚本,awk数组之如何处理多个文件。的主要内容,如果未能解决你的问题,请参考以下文章