How do I recursively grep through all sub-directories and find files containing given text / string or words?
You can use the -r option to recursively grep through all sub-directories and find text. The syntax is as follows:
grep -r "text" /path/to/di
In this example, search for an IP 192.168.1.254 in through all /etc/ and all its sub-directories:
grep -r "192.168.1.254" /etc/
Search in any case:
grep -ri "letters" /home/vivek/data
Use the -l switch to display only the names of files in which the text occurs:
grep -lri "foo" /data
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -

