My Input :
A.txt
1@A 2@B 3@C
1 4 5
2 4 5
3 4 5
B.txt
1 2 3
A B C
1 4 5
2 4 5
3 4 5
My Input :
A.txt
1@A 2@B 3@C
1 4 5
2 4 5
3 4 5
B.txt
1 2 3
A B C
1 4 5
2 4 5
3 4 5
Hello asavaliya,
Could you please try following and let me know if this helps.
awk 'NR==1{for(i=1;i<=NF;i++){split($i, A,"@");B=B?B OFS A[1]:A[1];C=C?C OFS A[2]:A[2]};print B ORS C;next} {print}' OFS="\t" Input_file
Output will be as follows.
1 2 3
A B C
1 4 5
2 4 5
3 4 5
NOTE: Above will check the first line and considering that it has only @
within letters then it should work.
Thanks,
R. Singh
Perfect !!!!!
Try also
awk '
NR==1 {T=$0
gsub (/@[^\t]*/, "")
print
$0=T
gsub (/[^\t]*@/, "")
}
1
' file
1 2 3
A B C
1 4 5
2 4 5
3 4 5