The UNIX and Linux Forums  

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 -->
  #6 (permalink)  
Old 03-18-2009
Mumford Mumford is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 2
You're seeing this because the find command passes the filenames it finds as a list of words separated by spaces. The problem is some of the files have spaces in the names. If you're on Linux or otherwise using GNU find & GNU xargs, you can use:


Code:
find . -type f -print0 | xargs -0 grep 'test result - pass' | wc -l

'print0' tells find to use \0 as the separator instead of space, and the -0 option to xargs tells it to accept \0 as the separator.

Last edited by Mumford; 03-18-2009 at 04:19 PM..