I often use grep twice with find in order to search for two patterns in a file as follows:
find . -name \*.xml | xargs grep -l "<beans" | xargs grep singleton
Then I ran into files with spaces which of course broke the above command. I modified it as follows to deal with the spaces:
find . -name \*.xml -print0 | xargs -0 grep -l "<beans" | xargs grep singleton
The option -print0 tells find to use print null as a separator instead of space and -0 tells xargs to expect a null. This works as long as none of the files I am looking for have spaces in their paths, but it breaks if they do.
So what I need is a flag to tell grep to print null as a speartor instead of newline.
Any ideas?