Jeremy's Notes

The Reverie of a Techie


Sidebar

What is this thing?

You've stumbled across a blog that chronicles the interests of its author. You'll find technology how-tos, demonstrations, recommendations, and reviews. Stand by!




Follow me on Twitter, Facebook, and other social networks.

How to find files containing specific text in Linux?

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

Share

Tags

~~DISCUSSION~~

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.

Read our privacy policy and how we use cookies

blog/linux_search_file_contents.txt ยท Last modified: 2021/01/09 15:47 by 127.0.0.1