I have a file system.xyz with several columns:
43
Built with Packmol
O 37.536208 36.873149 9.514500
C 37.768292 35.784076 10.014380
N 37.749829 34.667899 9.235406
C 38.014779 33.336113 9.750827
C 37.921777 32.283049 8.635104
C 38.203826 30.885654 9.187454
and need to change them to:
@atom:o1 @mol: $atom:O 0 37.536208 36.873149 9.514500
@atom:c1 @mol: $atom:C 0 37.768292 35.784076 10.014380
@atom:n1 @mol: $atom:N 0 37.749829 34.667899 9.235406
@atom:c2 @mol: $atom:C 0 38.014779 33.336113 9.750827
@atom:c3 @mol: $atom:C 0 37.921777 32.283049 8.635104
@atom:c4 @mol: $atom:C 0 38.203826 30.885654 9.187454
I have managed to use this
grep -A43 Built system.xyz | awk '{print "@atom:"tolower($1), "@mol: $atom:"$1,"0",$2,$3,$4}'
@atom:built @mol: $atom:Built 0 with Packmol
@atom:o @mol: $atom:O 0 37.536208 36.873149 9.514500
@atom:c @mol: $atom:C 0 37.768292 35.784076 10.014380
@atom:n @mol: $atom:N 0 37.749829 34.667899 9.235406
@atom:c @mol: $atom:C 0 38.014779 33.336113 9.750827
@atom:c @mol: $atom:C 0 37.921777 32.283049 8.635104
@atom:c @mol: $atom:C 0 38.203826 30.885654 9.187454
but I have to manually enter the indexes of each character of the first column. Is there a way to count and index the characters in the first column?