let i have A file and B file
A has contains 4 fields as below
----------------
f1 f2 f3 f4
B file consists of 5 fields as below
--------------------
f5 f6 f7 f8 f9
need to display as below output:
f5 f1 f3 f8 f9
let i have A file and B file
A has contains 4 fields as below
----------------
f1 f2 f3 f4
B file consists of 5 fields as below
--------------------
f5 f6 f7 f8 f9
need to display as below output:
f5 f1 f3 f8 f9
try:
awk 'NR==FNR {f[1,FNR]=$1; f[3,FNR]=$3; next;} {$2=f[1,FNR]; $3=f[3,FNR]; print;}' A B
$ cat sample11.txt
f1 f2 f3 f4
$ cat sample12.txt
f5 f6 f7 f8 f9
$ paste -d" " sample11.txt sample12.txt | awk '{print $5,$1,$3,$8,$9}'
f5 f1 f3 f8 f9