Search for text

Search for a string and only print the lines that were matched

$ sed -n '/hello/p' file.txt

Case insensitive search

$ sed -n '/hello/Ip' file.txt

Search for a string but only output lines that do not match

$ sed -n '/hello/!p' file.txt
Comments