Delete comment from: Javarevisited
Hobbit said...
Piping a list of file nnames through "xargs grep" will fail if "find" locates files that contain spaces in their names, since by default "xargs" splits the incoming list on spaces. In that case, use "-print0" on the "find" command to separate file names with nulls, and "-0" on "xargs" to tell it the file names are null separated.
For example,
$ cd ~/Documents
$ find . -name '*.txt' -print0 | xargs -0 grep -i 'some text'
Note I've also quoted '*.txt' on the find command to prevent the shell from expanding any file names in the current directory that may end with '.txt'.
Mar 19, 2011, 10:23:48 AM