linux 实现两个文件指定列的替换

1、

root@PC1:/home/test2# ls
test1.txt  test2.txt
root@PC1:/home/test2# cat test1.txt
01 02 03 04
05 06 07 08
09 10 11 12
13 14 15 16
17 18 19 20
root@PC1:/home/test2# cat test2.txt
17 18 19 20
13 14 15 16
09 10 11 12
05 06 07 08
01 02 03 04
root@PC1:/home/test2# awk 'FNR==NR{a[NR]=$2;next}{$4=a[FNR]}{print}' test1.txt test2.txt   ## 使用test1.txt的第2列替换test2.txt的第4列,原理不清楚
17 18 19 02
13 14 15 06
09 10 11 10
05 06 07 14
01 02 03 18
原文地址:https://www.cnblogs.com/liujiaxin2018/p/15735254.html