This is the mail archive of the cygwin 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: [ANNOUNCEMENT] Updated [test]: grep-3.0-2


On Tue, 14 Feb 2017 10:17:25, "Eric Blake (cygwin)" wrote:
> This build modifies the behavior of grep to no longer force text mode on
> binary-mounted file descriptors.

Works, thanks:

    $ printf 'hello world\r\n' | grep . | od -tcx1
    0000000   h   e   l   l   o       w   o   r   l   d  \r  \n
             68  65  6c  6c  6f  20  77  6f  72  6c  64  0d  0a

> Since this includes pipelines by default, this means that if you pipe text
> data through a pipeline (such as the output of a windows program), you may
> need to insert a call to d2u to sanitize your input before passing it to grep.

This is certainly a good way to do it, but for more portable solution use tr:

    $ printf 'hello world\r\n' | tr -d '\r' | od -tcx1
    0000000   h   e   l   l   o       w   o   r   l   d  \n
             68  65  6c  6c  6f  20  77  6f  72  6c  64  0a


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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