![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| find , grep | james94538 | UNIX for Dummies Questions & Answers | 3 | 10-09-2008 09:03 PM |
| grep, find or awk? | netrom | UNIX for Dummies Questions & Answers | 4 | 04-09-2008 05:03 PM |
| grep and find | MEllis5 | UNIX for Dummies Questions & Answers | 1 | 04-07-2008 08:16 AM |
| find then grep | flame_eagle | Shell Programming and Scripting | 7 | 03-13-2008 11:19 AM |
| find & grep | Anika | UNIX for Dummies Questions & Answers | 11 | 02-01-2001 12:19 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
find and grep
Hi,
I need to find out a particular pattern from a directory, for example say X. The X directory contains 10 c files, and it has subdirectory called Y, and Y has 20 c files within it. Now I have to find out the pattern only from parent directory X not from sub directory Y. I have used this type of command X> find . -name "*" | xargs grep -l "getsum" It will retrive result from sub directory also.....I need only for the parent dir. Thanks Sarwan |
|
||||
|
find X/ -name "*" | xargs grep -l "getsum"
This one also retrives pattern file name from the sub directory. find X/ -name "*" | xargs grep -l "getsum" it gives the same o/p as this find . -name "*" | xargs grep -l "getsum". Last edited by sarwan; 04-10-2006 at 05:22 AM.. Reason: More clarity |
|
||||
|
Whether you give absolute or relative path, find drills down into all the subdirectories starting from the path specified.
So you may as well try out, find . \( ! -name . -prune \) -type f | xargs grep -l "pattern" "prune" prevents going into sub-directories. Last edited by manthasirisha; 04-10-2006 at 05:52 AM.. Reason: typo error |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|