![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| count the number of files which have a search string, but counting the file only once | sudheshnaiyer | UNIX for Dummies Questions & Answers | 1 | 08-11-2007 10:50 AM |
| Search for Files that DONT contain a string | tonydsam | UNIX for Dummies Questions & Answers | 11 | 05-02-2006 12:05 PM |
| Search a string from list of input files | sivakumarvenkat | UNIX for Dummies Questions & Answers | 2 | 03-08-2006 02:08 PM |
| Search files for a string in the remote machine | a_rivu | UNIX for Dummies Questions & Answers | 2 | 06-14-2005 11:31 AM |
| Search all files for specific string | sureshy | UNIX for Dummies Questions & Answers | 4 | 03-06-2002 08:28 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
What is the Best way to search files for a string??
I'm looking to seach all the files in a directory and sub-directories looking for a string. When the string is found, I want to display the filename and the entire line of that file that the string was found on.
what is the best way to do this ?? I've been playing around with awk, find, and grep with no luck. I am on HPUX 11.11 thanks |
| Forum Sponsor | ||
|
|
|
|||
|
Ok, I'm getting closer. I found a grep command that is somewhat working.......
grep -i 'string' * This is giving me what I need, but is only searching the present directory. How do I get this command to also search the sub-directories ?? |
|
|||
|
I didn't use the backsticks the first time.....but received another error when using them in which I needed to CNTL C out of.
I copied my cmd prompts this time. The first command shows the grep command working on 2 test files that I have. I also have a sub-directory in /home/mark with another test file that I want it to find............ [unix] mark[426]: pwd /home/mark [unix] mark[427]: grep -i 'monkey' * find1.test:this line contains the word monkey. find2.test:this line contains the words monkey and turtle. grep: can't open oldetc [unix] mark[428]: grep -i 'monkey' `find` Usage: find path-list [predicate-list] [unix] mark[429]: grep -i 'monkey' ${find} sh: find: Parameter not set. [unix] mark[430]: |