Escape prime (') char in atom name for selection command

GROMACS version: 2024.2
GROMACS modification: No

I’m trying to select 4 atoms for dihedral computation using bash script of nucleic acid system:

for i in {2..85}; do
   gmx select -f ../npt.trr -s ../npt.tpr -on alpha_$i.ndx -select "name O3' and resindex $(($i-1)) or name P and resindex $i or name O5' and resindex $i or name C5' and resindex $i"
done

The first problem is that I can’t escape the prime char in atom names (like in name O3’).
Any suggestions? Better solution?
Anyway could be usefull to deal with this problem…

Best Regards

Dear @Alex_Beer

This seems a bash related problem rather that a GROMACS one. Generally, in bash scripting you can escape characters with the \ character, have you tried it? Something like:

for i in {2...85};
do
gmx select -f ../npt.trr -s …/npt.tpr -on alpha_i.ndx -select "name O3\′ and resindex (($i-1)) or name P and resindex $i or name O5\’ and resindex $i or name C5\’ and resindex $i"
done

I’ve tried few combinations of quote chars, with the command:

gmx select -f ../npt.gro -on alpha_$i.ndx -select "name O3\'"
I get

Command line:
  gmx select -f ../npt.gro -on alpha_85.ndx -select 'name O3\''


-------------------------------------------------------
Program:     gmx select, version 2024.2-dev
Source file: src/gromacs/commandline/cmdlineparser.cpp (line 271)
Function:    void gmx::CommandLineParser::parse(int*, char**)

Error in user input:
Invalid command-line options
  In command-line option -select
    Invalid selection 'name O3\''
      Near '\'
        syntax error

Also tried param “-sf” with selection string (that inside double quote") but no luck.

In the page of gromacs selection is reported that regex expression are supported but I don’t undertood how to use them.

I have the same problem, did anybody ever find a solution for this?