Save trajectory frame based on rmsd value

GROMACS version:2022
GROMACS modification:No
BS"D

Hi,

Is there a way to use gmx rms and if a frame has an rmsd above or below a certain value relative to the reference structure, save that frame in a new xtc file?

Thanks

Harry