GNU grep and files with nulls

Liste des GroupesRevenir à cu shell 
Sujet : GNU grep and files with nulls
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.unix.shell
Date : 12. Apr 2025, 16:03:13
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <vtdvbh$1k2sl$1@news.xmission.com>
User-Agent : trn 4.0-test77 (Sep 1, 2010)
So, I have a file that contains a line like:

    foo.bar.bletch.one.two

where the dots represent null (\0) characters.

I want to be able to grep this line, using this command:

    grep foo.bar.bletch.one.two file

where the dots represent actual dots (regexp wildcards).
(I do it this way because I don't know how to represent a null character in
a grep RE; using dots instead gets you a "good enough for government work"
result)

Interestingly, in grep version 2.20, this worked as expected, but in grep
version 3.3, it fails.  I found this out when the above code stopped
working, when the code was moved to a newer Linux system (which had the new
version of grep installed).

This is all out of curiosity, of course.  I know this is a grey area in
terms of standards and stuff like that, but it seems odd that they would
actually removing working functionality.  The man page says little on the
subject; it does mention nulls in a few places, but it seems not relevant
to this issue.

Anyway, I switched the code to use GNU AWK (Gawk), which explicitly
supports nulls in strings, so no worries there.  The Gawk solution is shorter
and cleaner anyway.

--
 "They say if you play a Microsoft CD backwards, you hear satanic messages.
  Thats nothing, cause if you play it forwards, it installs Windows."

Date Sujet#  Auteur
12 Apr 25 * GNU grep and files with nulls3Kenny McCormack
12 Apr 25 `* Re: GNU grep and files with nulls2John McCue
12 Apr 25  `- Re: GNU grep and files with nulls1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal