This also happens when doing "grep -L" for something that -is- in the file, redirected to /dev/null:
====== $ echo hello > thing $ grep -L hello thing; echo $? 1 $ grep -L hello thing > /dev/null; echo $? 0 ======= My first guess, after a minute glancing at the code, and after using strace to notice that grep doesn't even try to invoke a "write(2)" system call in these examples, if it notices that its output is redirected to /dev/null, is that the exit status of the grep command depends sometimes, somehow, on whether or not it decided to write out any results at all. My strace observations in the previous paragraph are probably reliable. My guess as to the logic grep is using to determine it's process exit status are probably not reliable. -- Paul Jackson p...@usa.net