Deleting unwanted water molecules using GROMACS?

GROMACS version: 2020
GROMACS modification: No
Here post your question:
Hello dear Gromacs users;
I want to delete water molecules inside a nanotube, I have obtained the serial number and ResID of the unwanted water atoms using VMD, but I was not able to use delatom command in VMD to remove them (Error [psfgen: no segment] even after defining segID for them).

Given that I can provide the atom serial number of bad water as an index file, I was wondering if there is any module in GMX that can help me removing these unwanted atoms?
If not, appreciate it if you could help me circumventing this problem
Thanks in advance

If you already have the index groups of the bad waters, use gmx make_ndx to create the complement to that group (e.g. if the bad water group is 15, you can simply use !15 to generate a group with everything else). Then use gmx trjconv with that index group to save the coordinates that are not the bad waters.