Searching For and Inside Files (find, grep)

image_pdfimage_print

The command find is used to find files with various attributes. It has many options. This makes it somewhat awkward for just searching for a file by name. For example, the command

finds all the files in the current directory and any directories below that have a name which ends in .tex and then prints the result of the search at the terminal.

The program grep looks inside files for specified text. For example,

will search the file paper.tex for any occurrences of the text Diophantine” and then then print those lines at the terminal. If you are searching in more than one file as in grep Diophantine *.tex it will print the name of the file in which the line was found.