I need to remove all the lines inside a file that contains a certain string more than once, for example if my file is like this:
This is a test toRemove first line
This is a test toRemove second line toRemove
Should produce a file like with only the first line
This is a test toRemove first line
I am trying to do this on linux from command line and I tried to use grep or sed like this
grep -d "toRemove.*toRemove" myFile > myOtherFile
sed '/\toRemove.*toRemove/!d' myFile > myOtherFile
But nothing seems to work. Does anybody know how to obtain this?