Want to grep data from column header and match with second file.
File A.txt
1 2 3 4 5 6
X1 A L D J Q R
X2 B M K P w T
X3 C S L P e Y
X4 R Z M A r U
FileB.txt
1
2
3
4
6
7
FileC.txt
1 2 3 4 6 7
X1 A L D J R n/a
X2 B M K P T n/a
X3 C S L P Y n/a
X4 R Z M A U n/a
Well, I had this one, but waited for OP's attempts/ideas/thoughts:
awk '
FNR == NR {COL[++CNT]=$1
next
}
FNR == 1 {printf "%-8s", ""
for (i=1; i<=CNT; i++) printf "%-8s", COL
printf "\n"
next
}
{printf "%-8s", $1
for (i=1; i<=CNT; i++) printf "%-8s", $(COL+1)?$(COL+1):"n/a"
printf "\n"
}
' file2 file1
1 2 3 4 6 7
X1 A L D J R n/a
X2 B M K P T n/a
X3 C S L P Y n/a
X4 R Z M A U n/a