Delete line entries in a text file

How to delete a specific line from a text file (command line), for example.

hello
goodbye
goodbye
hello
hello
hello
goodbye

In this case, I would like to delete all occurrences of "goodbye"

Linux or Windows (until the Linux command is available on GNU)

+3
source share
1 answer
sed -i -e 's/goodbye//g' filename

To delete a few words:

sed -i -e 's/\(goodbye\|hello\|test\|download\)//g' filename
+8
source

All Articles