I have a file1.dat
and a file2.dat
containing values. I want to replace the values of the file2.dat
with the file1.dat
in the first column by changing the file format and data.
I tried this awk command, but problem is its changing the file format and the entire first column is getting changed.
awk 'NR==FNR{a[NR]=$0;next}{$1=a[FNR]}1' file1.dat file2.dat > result.dat
File1.dat (input):
A123456789 1 C HIE 1 48.343 23.545 32.02 1.00 0.00 H
A875678235 3 C PHE 1 48.343 23.545 32.02 1.00 0.00 C
A907654234 4 N ALA 1 48.343 23.545 32.02 1.00 0.00 N
A907863544 5 B VAL 1 48.343 23.545 32.02 1.00 0.00 B
File2.dat (input):
987654321
567890123
098765432
890765348
Desired output:
A987654321 1 C HIE 1 48.343 23.545 32.02 1.00 0.00 H
A567890123 3 C PHE 1 48.343 23.545 32.02 1.00 0.00 C
A098765432 4 N ALA 1 48.343 23.545 32.02 1.00 0.00 N
A890765348 5 B VAL 1 48.343 23.545 32.02 1.00 0.00 B