help-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Creating strings of binary zero characters


From: pjfarley3
Subject: RE: Creating strings of binary zero characters
Date: Tue, 31 Aug 2021 20:14:16 -0400

Thanks Wolfgang, I did already know about embedding nulls in constant strings 
with \x00 or \000, but I wanted something a bit more general for my very small 
project.

The header prefix is a known length so typing it out one time as a constant 
string would work, but I wondered if it could be dynamically constructed.

I should have said "dynamically" more clearly in my original question, but I 
did say "generate a string . . . " trying to imply dynamic creation.

Thanks for the reply.

Peter

> -----Original Message-----
> From: Help-gawk <help-gawk-bounces+pjfarley3=earthlink.net@gnu.org> On
> Behalf Of Wolfgang Laun
> Sent: Tuesday, August 31, 2021 12:21 PM
> To: Help Gawk List <help-gawk@gnu.org>
> Subject: Fwd: Creating strings of binary zero characters
> 
> You can create character values in hex or octal notation. So here you have two
> null characters in a string:
>     BEGIN {  print "NULL:\x00NULL:\000\n"; } Here are the NULL characters in 
> the
> output:
>    wlaun@terra:/tmp$ gawk -f null.awk  | od -tx1
>    0000000 4e 55 4c 4c 3a 00 4e 55 4c 4c 3a 00 0a 0a
> 
> WL
> 
> On Tue, 31 Aug 2021 at 17:26, <pjfarley3@earthlink.net> wrote:
> 
> > I have an application that needs to generate a header record in an
> > otherwise text file where the header record has a key of binary zero
> > characters in the first N bytes followed by normal text data like
> > current date and other file-identifying information.
> >
> > Is there a way to generate a string of binary zero characters of
> > length N using only gawk?  Or do I need to use another tool to accomplish 
> > that
> task?
> >
> > Peter
> 
> --
> Wolfgang Laun
--




reply via email to

[Prev in Thread] Current Thread [Next in Thread]