The UNIX and Linux Forums  
Hello and Welcome from to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 01-23-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
Quote:
Originally Posted by tiger99 View Post
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
command 2 searches for filenames that have the string "test" as part of their name while command 1 searches for the string "test" inside each of the files.

Code:
ls -R | xargs grep "test"  #this makes command 2 like command 1