bug-gawk
[Top][All Lists]
Advanced

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

Re: Read a fixed length of input each time


From: arnold
Subject: Re: Read a fixed length of input each time
Date: Tue, 23 Jun 2020 01:27:18 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Hi.

Peng Yu <pengyu.ut@gmail.com> wrote:

> Hi,
>
> I'd like to read a binary in chunks of in bytes.

Using gawk to read binary data is not recommended. It's a tool
for processing textual data.  You may want to preprocess the
binary using C (or perl) into text records that gawk can process.

> awk by default uses
> RS to split the input as records. Is there a way to split the input in
> chunks with fixed length instead of using a deliminator? Thanks.

There is no way to do this built-in to gawk. I've thought about it in
the past but never implemented anything. Nor am I likely to do so
in the future.

It is fairly easy to write a C extension that would do this.

> PS. I see the following. But I am not sure if it is appropriate for my
> specific question.
>
> https://www.gnu.org/software/gawk/manual/html_node/Fixed-width-data.html

Likely it is not. It's intended for proessing columnar data, but in
regular, line-oriented records.

Arnold



reply via email to

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