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
-ror-Ris recursive search-nis show line number of matches-wis find match for the whole word-eis the word pattern you’d like to search