bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep to a file adds x'0D'


From: Eric Blake
Subject: Re: grep to a file adds x'0D'
Date: Wed, 20 Jun 2012 14:44:09 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0

On 06/20/2012 07:42 AM, Gary Aderhold wrote:
> I'm using GNU grep 2.5.4.  I'm grepping a binary file in Windows that
> has record delimiters of CRLF  (x'0D 0A').  My grep selects the proper
> rows, but, when sending the results to a file, it's adding a CR to the
> end of each record.  So, now my records all end with x'0D 0D 0A'.

That sounds like a case of your version of grep opening input files in
binary mode, but output files in text mode.  Either grep should open ALL
files in binary mode, or ALL files in text mode (and I prefer binary
mode, as it is less likely to strip CR when I want it preserved).

But this is not a bug in upstream grep.

> 
> Is this a bug?  Or, is there a way to tell grep to NOT add this extra
> x'0D' byte?

You'll need to investigate this with whoever made the particular grep
binary for windows, and figure out why their port is mixing binary and
text modes.  They may have also provided a --binary command-line option,
and if using that option fixes your problems, you have a workaround.

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org



Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]