How to keep only the last group in the NDX file?

Using the following command I create a new group in the NDX file for the C-alpha atoms of the residues in range of 8 to 195:

gmx make_ndx -f ref.pdb -o new.ndx << EOF
ri 8-195 & 3
q
EOF

Is it possible to change the number of this new group e.g. setting it to the 0 group (without explicit definition of the number of new group) ?

I found only ony possibility to add keep number_of_new_group that will deleate all other groups but in this case I still need to define the number of new group.

Many thanks in advance

Cheers

Not in a trivial way, numbers are assigned based on the order of entries. But you can always calculate the index of the last group in your script by counting headers:

lastindex=$[$(cat new.ndx | grep "\[" | wc -l) - 1]

and use $lastindex in your scripting (assuming this is where you’re going).

You can also create single-group indices with this gromologist feature, this way your selection will always be numbered as 0.