The Very Useful grep Command for Searching General Keywords in Command Line
•
0 min read
Quick tip: If you are ever in a situation where you want to search for a keyword in every file of a directory (or even the entire computer), a very useful command line tool is grep
(manual), which print lines of any file names, or any lines of text inside a file, that matches a defined pattern. Sample usage is as follows:
grep -rnw '/path/to/somewhere/' -e 'word pattern'
where
-r
or-R
is recursive search-n
is show line number of matches-w
is find match for the whole word-e
is the word pattern you’d like to search