I have a long file that looks like this:
ATOM 55 CE1 LIG X 1 -2.921 4.159 -10.046 1.00 0.00 LIGA
I need to take the first letter of the third column, in this case C (but it changes by line), and replace my last column, LIGA, with this character. I need to do this while ensuring the spacing between my 12th and 13th columns is 11, as shown below. I need it to be identical to the line below for my program to understand it.
ATOM 55 CE1 LIG X 1 -4.950 9.318 4.387 1.00 0.00 C
I managed to copy the first letter of the third column into a different file, then delete the 13th column from the original file, and paste the different file into the original file with the lines below. However, I can find a way to fix the spacing.
cut -c 14 original.pdb > different.pdb
perl -pi -e 's/LIGA//g' original.pdb
paste original.pdb different.pdb >> joint.pdb
mv joint.pdb original.pdb
I know awk may work here. I haven't been able to achieve it. I appreciate the help!