====== How to find files containing specific text in Linux? ====== {{ :blog:linux_search_file_contents.png?nolink&150|Penguin by Lars Meiertoberens from the Noun Project}} If you would like to find a specific string of text within a directory of files, you can use the following command and example: user@host:~$ grep -rnw '/path/to/directory/' -e 'searchterm' Here's a breakdown of the example command and its parameters: * ''-r'' or ''-R'' will recursively (within directories) look at all files within the specified path. * ''-n'' will display the line number where the term shows up within each file. * ''-w'' Matches the whole word. ===== Sources ===== * [[https://linuxcommand.org/lc3_man_pages/grep1.html|grep Manpage]] ===== Share ===== ~~socialite~~ ===== Tags ===== {{tag>Linux How-to}} ~~DISCUSSION~~ ~~Article~~ ~~NOTOC~~