Q: On the UNIX systems, how do I delete every line in a file that has the word "outdated" in it?
A: The two easiest ways are using the grep -v command at the UNIX prompt or the ex/vi g and d commands.
Using grep -v
The UNIX grep command lets you search for a string in one or
more files. The "-v" option tells grep to display lines that do
not have the information you tell it to search for.
To summarize: this command searches the file "myfile" for the text "outdated", and puts all lines that do not have "outdated" in them into the file "myfile.new".
This command searches the file "myfile" for the text "outdated"--no matter whether upper-case or lower-case letters have been used--and puts all lines that do not have "outdated" in them into the file "myfile.new".
This command searches the file "myfile.new" for the text "out dated"--no matter whether upper-case or lower-case letters have been used--and puts all lines that do not have "out dated" in them into the file "myfile.newer".
Using vi global commands
Using vi, you can issue global commands from command mode.
If you are not sure of the case used, you can issue this command
from vi command mode before you make the global change:
:set ic
(set ignorecase)