*Why* does using /dev/null in find/grep display the file name?

Posted by Jonathan on Super User See other posts from Super User or by Jonathan
Published on 2010-05-13T12:38:58Z Indexed on 2010/05/13 12:44 UTC
Read the original article Hit count: 199

Filed under:
|
|
find . -name "*.java" -exec grep "foo" {} \;

This just prints matches, no file name.

find . -name "*.java" -exec grep "foo" /dev/null {} \;

But this prints file name as well.

Why? What are the mechanics of find/grep that cause file name to print when /dev/null is inserted into the mix?

PS - yes, I know I can do "grep -H"

© Super User or respective owner

Related posts about unix

Related posts about find