Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 09-30-2002, 02:36 AM   #1
Registered: Sep 2002
Location: fdas
Posts: 100

Rep: Reputation: 15
grep file in the subdirectory

The 'grep' function can only use in the current directory, how to grep file into the subdirectory ? Thx.
Old 09-30-2002, 03:06 AM   #2
Registered: Mar 2002
Location: Elyria, Ohio
Distribution: Debian, Nothing else required
Posts: 141

Rep: Reputation: 15
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

Old 09-30-2002, 09:08 AM   #3
Senior Member
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
You can also use find with grep to narrow down your search. For example:
find /etc -type f -exec grep DHCP {} \;
Old 09-30-2002, 11:08 AM   #4
Registered: Jul 2002
Location: san francisco
Distribution: freebsd
Posts: 102

Rep: Reputation: 17
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
grep throughout the whole file system....? vous Linux - Software 4 03-20-2005 01:30 PM
Using grep, etc to modify a text file dangerousdave Linux - Newbie 7 02-23-2005 02:49 PM
output to a file - cat? grep? Godsmacker777 Linux - Newbie 6 12-08-2004 10:06 AM
Need help with grep, trying to parse/filter a file... patsnip Programming 4 08-29-2003 02:33 PM
grep a line in a file from dir bkeating Linux - Newbie 4 07-24-2003 02:04 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:28 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration