how to delete all lines in text file that do not contain character x in linux code example Example: delete lines text file linux sed -i '' '/pattern to match/d' ./infile