public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: OT: grep for \x00 = NUL
       [not found] <md5:2B2CF516B327FFCA0D2F3F274C35F083>
@ 2005-07-19 16:41 ` Brian Dessent
  2005-07-19 17:15   ` fftw library javier sacristan
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Dessent @ 2005-07-19 16:41 UTC (permalink / raw)
  To: cygwin

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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* fftw library
  2005-07-19 16:41 ` OT: grep for \x00 = NUL Brian Dessent
@ 2005-07-19 17:15   ` javier sacristan
  0 siblings, 0 replies; 3+ messages in thread
From: javier sacristan @ 2005-07-19 17:15 UTC (permalink / raw)
  To: cygwin

Hi, and thanks for your help, I would like to know if someone has already
installed a FFTW library to perform Fourier transforms. If so, could you
explain me how to do it?

Thank you


Javier



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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* OT: grep for \x00 = NUL
@ 2005-07-19 16:22 fergus
  0 siblings, 0 replies; 3+ messages in thread
From: fergus @ 2005-07-19 16:22 UTC (permalink / raw)
  To: cygwin; +Cc: fergus

Sorry, probably off topic but so tantalising and so easily stated I thought
I'd try you. Using grep to locate hex characters in files I've used the
syntax

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

and found this to work for all \x01 to \xff, that's 255 of the 256 one might
be interested in looking for. (Well, I haven't tried them all, but a lot of
them.) What I still can't do (actually, what I most wanted to do) is search
for the NUL \x00. Nothing in info bash indicated that this approach would
not work for \x00, but as far as I can tell, it doesn't: files that do not
contain \x00 are listed as containing it (try grep $'\x00' *).

Is it a bug?

Any ideas? (This has cropped up before but sorry I can't seem to find it.
Various suggestions included piping output from od to grep, but this
approach just involving grep seems much more direct if it can be made to
work.)

Fergus


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-07-19 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <md5:2B2CF516B327FFCA0D2F3F274C35F083>
2005-07-19 16:41 ` OT: grep for \x00 = NUL Brian Dessent
2005-07-19 17:15   ` fftw library javier sacristan
2005-07-19 16:22 OT: grep for \x00 = NUL fergus

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).