cat

"Carroll, Jim" <[email protected]>
Newsgroups gmane.comp.gnu.textutils.bugs
Message-ID <[email protected]>
Sample text file: file.txt
--------------------
Hello
there
-------------------

run:
cat file.txt | egrep -e "o$"
you will get nothing

run:
egrep -e "o$" file.txt'
you will get "Hello"

run:
egrep -e "^" file.txt | egrep -e "o$"
you get "Hello"

if you compare the result of runing:
cat file.txt
with:
egrep -e "^"
they look the same.

It seems 'cat' is chaning the output such that 'egrep' (grep -E) can't match the end-of-line marker correctly. Interestingly enough if you dont include a carrage return after the 'there' in the file then it seems to pick up 'cat file.txt | egrep -e "e$"' just fine or if you try this: 'cat file.txt | egrep -e "$"' it also seems to do what you would expect.

For the time being I have replaced cat.exe with a shell script as follows:
---------------------------
#!/bin/sh

egrep -e "^" $1
--------------------------

and that seems to be working for me. But this does seem like a bug.

Jim Carroll
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.