convert script awk in python

Avi Gross avigross at verizon.net
Wed Mar 24 19:30:45 EDT 2021


Just to be clear, Cameron, I retired very early and thus have had no reason
to use AWK in a work situation and for a while was not using UNIX-based
machines. I have no doubt I would have continued using WK as one part of my
toolkit for years albeit less often as I found other tools better for some
situations, let alone the kind I mentioned earlier that are not text-file
based such as databases.

It is, as noted, a great tool and if you only had one or a few tools like it
available, it can easily be bent and twisted to do much of what the others
do as it is more programmable than most. But following that line of
reasoning, fairly simple python scripts can be written with python -c "..."
or by pointing to a script

Anyone have a collection of shell scripts that can be used in pipelines
where each piece is just a call to python to do something simple?

-----Original Message-----
From: Cameron Simpson <cs at cskk.id.au> 
Sent: Wednesday, March 24, 2021 6:34 PM
To: Avi Gross <avigross at verizon.net>
Cc: python-list at python.org
Subject: Re: convert script awk in python

On 24Mar2021 12:00, Avi Gross <avigross at verizon.net> wrote:
>But I wonder how much languages like AWK are still used to make new 
>programs as compared to a time they were really useful.

You mentioned in an adjacent post that you've not used AWK since 2000.  
By contrast, I still use it regularly.

It's great for proof of concept at the command line or in small scripts, and
as the innards of quite useful scripts. I've a trite "colsum" script which
does nothing but generate and run a little awk programme to sum a column,
and routinely type "blah .... | colsum 2" or the like to get a tally.

I totally agree that once you're processing a lot of data from places or
where a shell script is making long pipelines or many command invocations,
if that's a performance issue it is time to recode.

Cheers,
Cameron Simpson <cs at cskk.id.au>



More information about the Python-list mailing list