Quantcast
Channel: egrep
Viewing all articles
Browse latest Browse all 5

Linux: Recursive file searching with grep -r (like grep + find)

$
0
0
Linux: Recursive file searching with grep -r (like grep + find) alvin July 23, 2019 - 7:46pm

Linux grep FAQ: How can I perform a recursive search with the grep command in Linux?

Solution: find + grep

For years I always used variations of the following Linux find and grep commands to recursively search subdirectories for files that match a grep pattern:

find . -type f -exec grep -l 'alvin' {} \;

This command can be read as, “Search all files in all subdirectories of the current directory for the string ‘alvin’, and print the filenames that contain this pattern.” It’s an extremely powerful approach for recursively searching files in all subdirectories that match the pattern I specify.


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images