romreservering NTNU: romres.ntnu.no

Find "some text" in files in current folder:

grep -lir “some text”

-l output only the names of files in which the text occurs

-i ignore case

-r descend into subdirectories

Find "some text" in "file", display 3 lines before and after finding:

grep -ir “some text” file -C 3 -B 3“

-i ignore case

-r descend into subdirectories

-C 3 display 3 lines after finding

-B 3 display 3 lines before finding