cygwin gnu grep thinks text files are binary
Paul McFerrin
MailHole@insight.rr.com
Thu Feb 21 17:25:00 GMT 2002
There was a posting within this past month about grep considering files
to be binary if the newlines were followed by \r. I'm assumming that
someone made note of that bug.
Just FYI, here is a filter I've written that removes \r from files. It
also preserves mtime::
=============================================================================
#!/bin/sh
if [ -f .._+_.. ]
then
rm -f .._+_..
if [ $? -ne 0 ]
then
echo "Failed to remove file \".._+_..\"" 1>&2
exit 2
fi
fi
trap '' 1 2 3 15
for f in $*
do
echo "Processing file: $f" 1>&2
mv $f .._+_..
if [ $? -ne 0 ]
then
echo "Failed to move file $f to \".._+_..\"" 1>&2
exit 2
fi
tr -d '\r' <.._+_.. >$f
touch -r .._+_.. $f
done
=============================================================
To use it:
$ rmcr files ...
-paul mcferrin
Benjamin Altman wrote:
>
> Hello,
>
> I was trying to do a grep against some html files I got through wget in
> Cygwin with the repeated message "Binary file xxx.html matches". Since grep
> thinks they are binary files I don't get to see any of the lines contained.
> Would anyone know why this is happening and how to get around this? The
> html files have ^M at the end of each line but I don't think that should
> cause this. Looking in the FAQ didn't help and I tried google searches
> without success.
>
> Thanks,
> Ben
>
> --
> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting: http://cygwin.com/bugs.html
> Documentation: http://cygwin.com/docs.html
> FAQ: http://cygwin.com/faq/
--
NOTE*** This email looks it came from MailHole@insight.rr.com but in
reality it came from pmcferrin@insight.rr.com. If you send
a reply to this message, it *should* get delivered to the
correct place.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list