[sed] Delete lines that match a pattern

Created on November 30, 2026

Add the d command after a pattern to omit matching lines from the output. The address /apple/ selects any line containing apple.

sed '/apple/d' dummy.txt

Example dummy.txt

apple
banana
apple pie
orange

Output

banana
orange

The original file is preserved. To edit it in place, use the -i syntax supported by your version of sed.

Bash Shell command sed