Jan Carlo Viray React · Angular · Node · Go · SQL · NoSQL · Cloud · Entrepreneurship

A year from now you’ll wish you started today — Karen Lamb

LinkedIn ·  Twitter ·  Github

How to Find Files Containing Specific Text

How to find files containing a specific text recursively in Unix / Linux system? I typically use grep like this:

grep -rnw "pattern" /path/to/file

Helpful options:

  • -r means recursively search
  • -n adds line number
  • -w matches the whole word, so remove it if you want partial match
  • -i for case insensitive search, but it’s a bit slow. Note that grep is case insensitive by default.
If you have any questions or comments, please post them below. If you liked this post, you can share it with your followers or follow me on Twitter!