Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Tue, 6 Apr 2004 15:19:46 -0400 (EDT)
From: Igor Pechtchanski <pechtcha@cs.nyu.edu>
Reply-To: cygwin@cygwin.com
To: fergus@bonhard.uklinux.net
cc: cygwin@cygwin.com
Subject: Re: Bogus assumption prevents d2u/u2d/conv/etal working on mixed files
Message-ID: <Pine.GSO.4.56.0404061458130.7366@slinky.cs.nyu.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Scanned-By: MIMEDefang 2.39

On Tue, 6 Apr 2004, fergus wrote:

> >> GNU grep detects binary files by looking for a '\0' byte.
>
> I know this is not strictly Cygwin-specific but it _is_ generated by the
> preceding relevant recent comment in a busy thread:
>
> Please can you tell me how to grep for an ASCII 00 (and for that matter
> anything from ASCII 1B to 1F, and 7F to FF)?
>
> (Or, I suppose in general for any of 00-FF though there's a "^A - ^Z" chunk
> at the beginning and a alphanumeric chunk in the middle, that are easily
> found by direct means.)
>
> Fergus

For anything but '\0', grep has no problem matching binary characters, so
you can use something like
	grep -a "`echo -ne "\01"`"
or
	grep -a "^V^A" (from the command line)
to match lines with ^A in them.  Unfortunately, grep uses '\0' as a string
terminator, so the above trick won't work with '\0'.  The best you can
hope to do with grep (or, for that matter, sed) is use "[[:cntrl:]]".

You *can*, however, use perl for this:
	perl -ne 'print if /\0/'

HTH,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

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

