![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| comparing the content of two directories | xyzt | UNIX for Dummies Questions & Answers | 2 | 04-29-2008 07:36 AM |
| searching files through all subdirectories beneath the current directory | milagros | Shell Programming and Scripting | 5 | 05-15-2007 01:00 PM |
| searching for content of files | Aretai | UNIX for Dummies Questions & Answers | 19 | 03-09-2007 03:44 AM |
| Searching for files over 30 days old in current directory | cxredd4 | Shell Programming and Scripting | 18 | 06-10-2006 11:16 PM |
| Searching and Removing File Content | rkumar28 | Shell Programming and Scripting | 7 | 02-27-2005 02:40 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
searching content of files in the current and sub directories
Hi
I was wondering why command 2 doesn't work like command 1 below. 1. find . -exec grep "test" '{}' \; -print 2. ls -R | grep "test" I am trying to search "test" from all the files in the current and sub directories. What's wrong with my command 2? Thanks in advance for your help |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
Code:
ls -R | xargs grep "test" #this makes command 2 like command 1 |
|
#3
|
|||
|
|||
|
Hi shamrock
Thanks for your help However the code you suggested ls -R | xargs grep "test" gives me a huge list with ending "No such file or directory". i.e. grep: expr.sh: No such file or direcotory Is it possible to only display the directory and file name when the text that I am searching is found? Thanks |
|
#4
|
|||
|
|||
|
try this :
find . | xargs grep -l "test" |
|
#5
|
|||
|
|||
|
2>/dev/null
Hi,
For the "No such file or directory", it is becuase there are error messages print to the stand output, you can ignore them by adding Code:
2>/dev/null |
|||
| Google The UNIX and Linux Forums |