public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Brian Dessent <brian@dessent.net>
To: cygwin@cygwin.com
Subject: Re: OT: grep for \x00 = NUL
Date: Tue, 19 Jul 2005 16:41:00 -0000	[thread overview]
Message-ID: <42DD2E12.458D22A1@dessent.net> (raw)
In-Reply-To: <md5:2B2CF516B327FFCA0D2F3F274C35F083>

fergus wrote:

>         grep $'\x0d' # e.g. equivalent to grep "^M"

Using that method you're passing the literal character to grep through a
bash quoting mechanism.  You can't pass a literal NULL as part of a
command line because argv[] consists of NULL-delimited strings, as do
most C string functions.

Why not just tell grep to look for a NULL rather than trying to feed it
an actual literal NULL character?

$ grep -P '\000'

In pcre regexps you can use \nnn to match any character represented by
octal nnn.  This would work for any character, and it doesn't rely on a
bash-specific shell feature.  But it does rely on grep supporting -P for
pcre, which is not universal.  If that cannot be relied on then you can
use

$ perl -ne 'print if m/\000/'

or

$ awk '/\000/ { print }'

Brian

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

       reply	other threads:[~2005-07-19 16:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <md5:2B2CF516B327FFCA0D2F3F274C35F083>
2005-07-19 16:41 ` Brian Dessent [this message]
2005-07-19 17:15   ` fftw library javier sacristan
2005-07-19 16:22 OT: grep for \x00 = NUL fergus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42DD2E12.458D22A1@dessent.net \
    --to=brian@dessent.net \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).