When chaining GnuWin32 commands in Windows cmd.exe, you may encounter strange error messages like this:
> ls | grep … ls: write error: Invalid argument
The first command reports a
write error but the error is really in the second command after the pipe symbol.
You may also encounter a similar write error if the wrong command is found in your PATH variable. For instance, Windows and GnuWin32 both have a find and sort command which support different command-line options, so depending on the order of directories listed in your PATH variable, one version or the other is used. If you enter the wrong command-line options for these commands, they won't start and cause the command earlier in the chain to report some sort of I/O error.