I have an auto_generated file that could have duplicate data, which causes my parser to crash. How can I check line-by-line and remove the unwanted lines based on a character that it has on bash ? For example:
for line in file.txt:
if '(1)' in line:
delete line
elif '(2)' in line:
delete line
elif '(3)' in line:
delete line
else:
return (file.txt with those lines removed )
Sample Input
Hello my name is john
Hello my name is eric
Hello my name is jonh(2)
Hello my name is ray
Hello my name is john (1)
Hello my name is eric (3)
Sample Output
Hello my name is john
Hello my name is eric
Hello my name is ray