procmail
[Top] [All Lists]

Re: hex value in condition

1997-08-09 02:35:00
On Sat, 09 Aug 1997 06:39:15 +0900,
Mitsuru Furukawa <furu(_at_)009(_dot_)com> wrote:
era eriksson <era(_at_)iki(_dot_)fi> wrote:
 era> accomplish the same thing. But if you have, for instance, printf(1) on
 era> your systems, there's definitely no need to go via Perl:
 era> HENSHIN=`printf "\xca\xd6\xbf\xae"`
 era> ASC=`printf "\x00-\xff"`
Thanks for suggestion.
I browsed printf man page but I could not locate appropriate option so far.

Huh? What "appropriate option"? Either you have it, or you don't. It
should accept more or less the same kinds of arguments as printf(3).

 $ which printf
 /usr/local/contrib/gnu/bin/printf

 $ printf "\x65\x72\x61\n"
 era

Some other candidates might be found with "man -k hex", or might not.
If you have twenty minutes extra time, get and install the GNU shell
utilities.

Even  sed -e '/"$HENSHIN"/,$d' did not match!

That would be

    sed -e "/$HENSHIN/",'$d'

Anything inside single quotes is passed literally, even double quotes.
Anything inside double quotes (and not inside single quotes) is
subject to interpolation. Anything not quoted will be broken up into
several arguments if it contains whitespace or other characters
regarded as separators by the shell (i.e. < > ; etc) and globbed. 
man sh

:0fbw
| perl -pe 's/^_* \xca\xd6\xbf\xae _*$/ccmailhenshinline/g' \
| sed -e '/ccmailhenshinline/,$d'
or
:0fbw
| perl -ne 'print if 1../^_* \xca\xd6\xbf\xae _*$/'
Though henshin line remains in second recipe, 
it might be a good idea to leave the line.
BTW, is there way to specify "print if not"?

In Perl, you can say "print unless" or, indeed, "print if (! condition)". 
Or you can specify the interval (/regex/ .. eof) instead. Or you can
quit when you reach the separator line:

    :0fbw
    | perl -pe 'last if /^_* \xca\xd6\xbf\xae _*$/'

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

<Prev in Thread] Current Thread [Next in Thread>