bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] FIELDWIDTHS extension request


From: Ed Morton
Subject: Re: [bug-gawk] FIELDWIDTHS extension request
Date: Mon, 22 May 2017 22:04:23 -0500
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1

great, thanks!

On 5/22/2017 9:57 PM, Arnold Robbins wrote:
Hi.

OK. I've added this feature to gawk's master. It'll be in the next
release. Andrew Schorr was helpful in shaking it out.  The doc
on FIELDWIDTHS has also been considerably revised and there are now
a number of additional tests.

The only thing that's allowed is '*' as the last field width
designator. None of the other flights of fancy discussed in
the comp.lang.awk thread will be implemented.

Thanks,

Arnold

Subject: Re: [bug-gawk] FIELDWIDTHS extension request
To: address@hidden, address@hidden
From: Ed Morton <address@hidden>
Message-ID: <address@hidden>
Date: Fri, 19 May 2017 07:45:00 -0500

People are really using it this way. I personally have to do it a couple of
times a year with different situations (parsing log files, schedules, etc. in
various formats) and then there's, for example, the following questions and
comments from people online using or best served by the same solution:

http://www.unix.com/unix-for-dummies-questions-and-answers/259428-find-replace-single-character-w-awk-given-conditions.html
https://unix.stackexchange.com/questions/208888/sed-replace-at-a-specific-group-of-positions
https://www.cpume.com/question/tfnznotf-formatting-output-in-bash-or-awk.html
http://blog.bogojoker.com/tag/gawk/
http://bida001.com/question/119893
http://stackoverflow.com/q/35178883/1745001
http://stackoverflow.com/q/26842477/1745001
http://stackoverflow.com/q/43942619/1745001
http://stackoverflow.com/q/24909124/1745001
https://groups.google.com/d/msg/comp.lang.awk/uip6-Ll9Lj0/_wMoc7lEAwAJ

Regards,

      Ed.

On 5/19/2017 4:13 AM, address@hidden wrote:
Is this request based on a theoretical discussion, or is someone
actually using FIELDWIDTHS do real work?

Thanks,

Arnold

Ed Morton <address@hidden> wrote:

Could we get an extension for FIELDWIDTHS such that a "*" (or some other
indicator) means "everything else"? It's very common to have to deal with files
like:

       foo  bar    stuff
       bill johnny other stuff of some different length

where it's easy to see the length of the first 2 fields but the length of the
final field can't be determined based on any sample so we end up writing code 
like:

       FIELDWIDTHS = "5 7 9999"

and pick some arbitrary number that we hope will be big enough to hold whatever
appears in that 3rd field. It would be clearer and more robust if we could
instead write:

       FIELDWIDTHS = "5 7 *"

or similar.

We've been having a discussion about the applicability of this at
https://groups.google.com/forum/#!topic/comp.lang.awk/uip6-Ll9Lj0 in case some
more background is useful.

Regards,

       Ed.




reply via email to

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