I have file with lines that start with two possible keywords, ATOM and HETATM. In some of those lines, there is a second keyword HOH, appearing after some other characters. In other lines, there are other 3-character keywords XXX like SOL instead of HOH:
ATOM  1231  O  XXX ...
HETATM1232  O  SOL ...
HETATM1233  O  HOH ...
What I want to do is to change HETATMs to ATOM only if HOH also appears on the line.
I tried the following:
sed -E '/\(HETATM\)\(.*HOH\)/s//\1ATOM/' file
which gives the illegal byte sequence error. What am I doing wrong?
 
    