Helpful Grep Command

Here is a helpful command I want to remember for the future.

grep -Rin "search term" directory

Grep is a search program for Linux. The options (also called switches or flags or arguments) come after the dash. (-)

The "R" option stands for Recursive. Grep will search within any directories that are within the directory argument. The "i" option makes the search ignore the case of the search term. The "n" option will list the line number where the search term is found.

The search term (in quotes) is what word you are searching for. Directory tells Grep where to start the search.

grep -Rin "Jeff" .

The above command will search for "Jeff" in the the current directory and all folders within it and display which files "Jeff" is in and what line. (if any) The period is short for "the current directory."

By @Jeff Bessette in
Tags : #journal, #linux, #command line