I often use the find command as such:
1
|
|
which looks for foo in all the PHP files. If the list of files gets too long for the shell, then xargs is the better option:
1
|
|
This breaks up the command into manageable chunks. The /dev/null is there in case xargs only passes one file name to the command, this ensures there will be two file names to trigger the printing of the matching file (there’s probably an option, but I like this way better)
The problem with find -print |xargs is that a file or directory with spaces causes problems. For instance “xxx yyy/blah.php” will run
1
|
|
neither of which exist.
My first hack at it was to revert to programmer mode and do a loop:
1
|
|
The best solution I found so far is to use -printf to force find to quote the file when it spits out the file name and get back into the xargs/stream mode of thinking:
1
|
|
Maybe there’s an easier way? (besides shooting people that use spaces in directory or file names)