-   Linux - Software (
-   -   Grep Recursive search directory depth option? (

timdvtemp 02-28-2011 03:29 PM

Grep Recursive search directory depth option?
I know grep can search recursively (ie through all subdirectories to the bottom of the directory tree), but is it possible to ask grep to only search say, 3 levels down? That means the current directory, any directories in the current directory, and within any directories within those?
Sounds confusing, but the problem is quite simple. Is the solution?

corp769 02-28-2011 03:49 PM

Maybe using find along side of grep?

grep text `find . -maxdepth 3 -type f`
This example will find the text "text" within all files found, with the max depth of three directories. I know this isn't exactly what you need, I'm sure you can work with it and figure something out. I would fix it up for you myself, but I'm at work and I don't have access to linux currently.



All times are GMT -5. The time now is 06:15 PM.