This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cygwin gnu grep thinks text files are binary

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::

if [ -f .._+_.. ]
	rm -f .._+_..
	if [ $? -ne 0 ]
		echo "Failed to remove file \".._+_..\"" 1>&2
		exit 2

trap '' 1 2 3 15
for f in $*
	echo "Processing file: $f" 1>&2
	mv $f .._+_..
	if [ $? -ne 0 ]
		echo "Failed to move file $f to \".._+_..\"" 1>&2
		exit 2
	tr -d '\r' <.._+_.. >$f
	touch -r .._+_.. $f

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:
> Bug reporting:
> Documentation:
> FAQ:         

NOTE***  This email looks it came from but in
          reality it came from  If you send
          a reply to this message, it *should* get delivered to the
          correct place.

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]