Grep is like the windows find command. The "." is not current directory, it's a regex pattern (like findstr uses). It means any character
I think i've narrowed it down to head rather than grep or some combination of head and grep..
Though interesting that one of the error messages made it look a bit like grep was giving the error. But I see I can get an error with head alone.
Code: Select all
C:\ff\ff>for /L %f in (1,1,500) do @echo zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz >>testfile
C:\ff\ff>type testfile | grep "." | head -n 1
The process tried to write to a nonexistent pipe.
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
C:\ff\ff>type testfile | grep "." | head -n 1
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
grep: writing output: Invalid argument
grep: writing output: Invalid argument
..
Interesting how I got different errors from the same command there. Sometimes i've only had the the "grep: writing output: Invalid argument" error.
As for what version of commands i'm using
C:\ff\ff>grep --v
GNU grep 2.5.4
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://g
This is free software: you are free to change and re
There is NO WARRANTY, to the extent permitted by law
C:\ff\ff>head --version
head (GNU coreutils) 5.3.0
Written by David MacKenzie and Jim Meyering.
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying co
warranty; not even for MERCHANTABILITY or FITNESS FO
C:\ff\ff>
C:\ff\ff>type testfile | findstr "." | head -n 1
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
FINDSTR: Write error
The process tried to write to a nonexistent pipe.
C:\ff\ff>
C:\ff\ff>head -n 1 testfile
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
C:\ff\ff>type testfile | head -n 1
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
The process tried to write to a nonexistent pipe.
C:\ff\ff>
though this works
C:\ff\ff>type testfile | findstr "." | find /n /v "asdf" | head -n 1
[1]zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
C:\ff\ff>
And this problem exists whether the file has windows line separators, (\r\n), or *nix new lines (\n).
UPDATE
interestingly I get the same error with sed (sed has an option which makes it behave like head, so I thought maybe sed wouldn't give the error and i'd use sed instead of head)
Code: Select all
C:\ff\ff>sed "2q" testfile
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
C:\ff\ff>type testfile| sed "2q"
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
The process tried to write to a nonexistent pipe.
C:\ff\ff>
No issue with grep but definitely an issue with gnuwin32 sed and head.
C:\ff\ff>type testfile| sed "1q" >a
The process tried to write to a nonexistent pipe.
C:\ff\ff>type testfile| grep "." >a
C:\ff\ff>
I recall there was this weird issue mentioned by dave benham with pipe and sides of it running in separate processes viewtopic.php?f=3&t=5905&start=15 where cmd /c resolved it.. But it doesn't apply / isn't relevant here, as even with cmd /c the error still appears.
Code: Select all
C:\ff\ff>cmd /c "type testfile | sed ^"1q^""
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
The process tried to write to a nonexistent pipe.
C:\ff\ff>cmd /c "type testfile | head -n 1"
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
The process tried to write to a nonexistent pipe.
C:\ff\ff>
It wouldn't surprise me if it was purely a bug in gnuwin32 implementations of sed and head.