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:06:02 -0400

Thanks David, that actually works and is straightforward.

I found by experiment that using gsub also works:

Pfx = "AAAAAAAAAA"
gsub(/A/, "\x00", Pfx)
print Pfx $0

Thanks again for the reply and code.

Peter

> -----Original Message-----
> From: Help-gawk <help-gawk-bounces+pjfarley3=earthlink.net@gnu.org> On
> Behalf Of david kerns
> Sent: Tuesday, August 31, 2021 12:08 PM
> To: pjfarley3@earthlink.net
> Cc: Help Gawk List <help-gawk@gnu.org>
> Subject: Re: Creating strings of binary zero characters
> 
> probably better way, but this  shows you can...
> 
> echo hello | gawk -vL=20 'BEGIN {s=sprintf("%c", 0);for(i=0;i<L;i++)o=o
> s;print o}{print}' > /tmp/padzero
> 
> On Tue, Aug 31, 2021 at 8:26 AM <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
--




reply via email to

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