LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   grep file in the subdirectory (https://www.linuxquestions.org/questions/linux-general-1/grep-file-in-the-subdirectory-31483/)

juno 09-30-2002 02:36 AM

grep file in the subdirectory
 
The 'grep' function can only use in the current directory, how to grep file into the subdirectory ? Thx.

mikek147 09-30-2002 03:06 AM

Try adding -d recurse to your grep search when using a directory as a source. As an example, from /, type:

grep -d recurse DHCP /etc

-mk

stickman 09-30-2002 09:08 AM

You can also use find with grep to narrow down your search. For example:
find /etc -type f -exec grep DHCP {} \;

leed_25 09-30-2002 11:08 AM

Quote:

Originally posted by stickman
You can also use find with grep to narrow down your search. For example:
find /etc -type f -exec grep DHCP {} \;

Of course, this forks a new process for each file which is grep'ped. Be nice to you cpu:

find /etc -type f -print|xargs grep DHCP


All times are GMT -5. The time now is 07:39 AM.