Jeremy's Notes

The Reverie of a Techie


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
blog:linux_search_file_contents [2021/01/02 16:03] – Added image. Jeremy McReynoldsblog:linux_search_file_contents [2021/01/09 15:47] (current) – external edit 127.0.0.1
Line 2: Line 2:
 {{ :blog:linux_search_file_contents.png?nolink&150|Penguin by Lars Meiertoberens from the Noun Project}} {{ :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: If you would like to find a specific string of text within a directory of files, you can use the following command and example:
-<code>grep -rnw '/path/to/directory/' -e 'searchterm'</code>+<code bash>user@host:~$ grep -rnw '/path/to/directory/' -e 'searchterm'</code>
  
-Here's a breakdown of the aforementioned example command and search parameters:+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.   * ''-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.   * ''-n'' will display the line number where the term shows up within each file.
Line 12: Line 12:
   * [[https://linuxcommand.org/lc3_man_pages/grep1.html|grep Manpage]]   * [[https://linuxcommand.org/lc3_man_pages/grep1.html|grep Manpage]]
  
 +===== Share =====
 ~~socialite~~ ~~socialite~~
 +===== Tags =====
 {{tag>Linux How-to}} {{tag>Linux How-to}}
 ~~DISCUSSION~~ ~~DISCUSSION~~
 ~~Article~~ ~~Article~~
 +~~NOTOC~~
blog/linux_search_file_contents.1609621386.txt.gz · Last modified: 2021/01/09 15:47 (external edit)