sed delete lines not containing specific string January 31, 2023 by Tarik This might work for you: sed '/text\|blah/!d' file some text here blah blah 123 some other text as well