I am using grep from Gnuwin32 on Windows.

On Windows XP, the following

grep -e "foo" NUL

results in the following output

grep: NUL: invalid argument

On Windows 7, the same arguments result in no output at all.

grep just exits without any error message.

Why is the output different between Windows XP and Windows 7?

  • do grep -v just to see if the versions are the same – barlop Aug 27 '11 at 1:56
  • i'm on windows xp C:\vin>grep --v shows GNU grep 2.5.4 And I get no output when doing C:\vin>grep -e "foo" NUL – barlop Aug 27 '11 at 1:58

NUL is the batch keyword for the null device (like /dev/null in linux) It is possible that in the second case, grep is correctly treating it as input, whereas in the first it is trying to access a file called 'NUL' (although this would not be the desired behavour since a file called 'NUL' cannot be created)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.