GNU bug report logs -
#41004
Documentation:enhancement - search for hexvalue
Previous Next
Reported by: Radisson97 <at> web.de
Date: Fri, 1 May 2020 17:07:01 UTC
Severity: wishlist
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 41004 <at> debbugs.gnu.org (full text, mbox):
On Fri, May 1, 2020 at 10:07 AM <Radisson97 <at> web.de> wrote:
> Hi,
> i had the problem of searching for a non-printable character in a long
> list of strings. I found nothing the documentation and but several discussion
> how to do that where either complicated or did not fit for my case, maybe i
> was unlucky, ntl i found a simple solution that should be mentioned in the
> documentation.
>
> problem: grep for a character where only the hexcode in known.
>
> solution: use $'\xNN'
> then shell expands this to the required code
>
> example: printf "A\nB\nC\n" | grep $'\x41'
>
> note: that uses only printable characters, it works also with anything else
> except \0 (i guess).
>
> i found that solution nice, it did no require any flags etc, for my problem it
> worked like a charm.
> (i am not member of the list please reply directly to this address) .
Thank you for the suggestion. Another approach is to use grep's -P option:
$ printf '%s\n' A B C| grep -P '\x41'
A
If you'd like to add an example to the documentation, please send a
patch, but I'm not sure how much of PCRE syntax we want to document in
grep's own manual.
This bug report was last modified 4 years and 245 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.