![]() |
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 |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Recursive grep | upstate_boy | UNIX for Dummies Questions & Answers | 16 | 05-18-2008 05:16 PM |
| Script problem due to recursive directories Help please | robertmcol | Shell Programming and Scripting | 2 | 04-27-2008 07:00 PM |
| recursive chmod that only affects directories? | retrovertigo | UNIX for Advanced & Expert Users | 1 | 06-22-2007 04:02 PM |
| recursive grep issue | Mace | UNIX for Dummies Questions & Answers | 1 | 08-11-2006 07:39 AM |
| recursive GREP ? | alan | UNIX for Dummies Questions & Answers | 3 | 08-22-2003 03:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I am trying to locate a file or files with specific data in them. Problem is the file(s) could reside in any one of many directories.
My question is. Is there a way of recursively greping directories for the file(s) with the data I am looking for. I have tried - 1. $HOME> grep 47518 | ls -R > results 2. $HOME> ls -R > grep 47518 3. $HOME> ls -R | grep 47518 Help please!!! ![]() |
|
|||||
|
Hi,
Sorry, I will try to make things a bit more clear : find /tmp -name \*ipt -exec grep pall {} \; -exec ls -l {} \; The find command you probably know. It searches for files or directorys where you want him to search and to what pattern to match. So : "find /tmp" says only start searching in /tmp "-name \*ipt" says to look for a file or directory ending with "ipt" the \ before the star says to not look for a file or directory named "*ipt" but to make it a pattern "-exec grep pall {} \;" says that the result of find in /tmp with the pattern ending on "ipt" should do the following : "grep pall /tmp/script" so {} \; is replaced with the current result. It's hard to explain the syntax, I think you should just take this as it is and copy the syntax when you need it ![]() "-exec ls -l {} \;" has the same syntax and executes the ls -l command for the current result. If you don't do this last -exec you don't know what file he grep the text from. Hope you understand it know. Don't forget there is always a man page from find. I know it is large, but there is so much beautifull to explore in the man from find !! @yourservice David |
![]() |
| Bookmarks |
| Tags |
| grep, grep recursive, recursive grep |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|