Deleting matching lines with sed removes unwanted records from a text stream or file without changing the surrounding rows. This is useful when a generated list, export, or log excerpt contains a known line category that should be excluded before review or handoff.
The d command deletes lines selected by a sed address. In sed '/status=remove/d' cleanup-list.txt, the address is the regular expression between the slashes, and only lines matching that expression are removed from the output.
Preview the deletion before editing a file in place. A broad pattern can remove more rows than intended, so the first check should keep the nonmatching rows visible and make the removed line category easy to recognize.
Related: How to remove blank lines with sed
Related: How to exclude matching lines with grep
host=db-01 status=keep host=db-02 status=remove host=web-01 status=keep host=web-02 status=remove host=cache-01 status=keep
Use a copy of an important file while testing the pattern. The examples below remove only rows containing status=remove.
$ sed '/status=remove/d' cleanup-list.txt host=db-01 status=keep host=web-01 status=keep host=cache-01 status=keep
sed treats the text between the slashes as a regular expression. Match a literal phrase when possible, or anchor the expression more tightly when a short word could appear in unrelated lines.
$ sed -i.bak '/status=remove/d' cleanup-list.txt
The d command removes every line that matches the address. Keep the .bak backup until the edited file has been reviewed.
The sed -i.bak form creates cleanup-list.txt.bak before saving the edited file, which avoids the GNU/BSD difference around no-backup in-place edits.
$ cat cleanup-list.txt host=db-01 status=keep host=web-01 status=keep host=cache-01 status=keep
The absence of status=remove rows in the final file is the success check. If a needed row disappeared, restore from cleanup-list.txt.bak and narrow the pattern before running sed again.