Re: sed and awk (Was: The "asort" extension (Was: feature proposal: expand ...
"G. Branden Robinson" <[email protected]>
| Newsgroups | gmane.comp.shells.bash.bugs |
|---|---|
| Message-ID | <20260827041135.b7i6a47fwvckddpk@illithid> |
At 2026-08-26T21:15:58-0600, Stan Marsh wrote:
> >I learned AWK programming because I was looking at some complex sed
> >expressions with { } command groups, b unconditional branches, and
> >whatnot. I wasn't happy with them and I want this script to be
> >intelligible to my coworkers. The AWK scripts that are there now are a
> >huge improvement. So yes, each has its place in my repertoire.
>
> The CW in the AWK group(s) is that once you get past "s/foo/bar/p" in
> sed, you should switch to AWK.
Well that group sure sounds like a good place to find an opinion on AWK
that is free of bias, good-natured or otherwise.
> Going any further with sed is just asking for pain and suffering.
Not in my view. It can be asking oneself to think more carefully and
clearly about what one is trying to do with a text transformation.
For me, personally, what I'd call "stateful" sed scripts, by which I
mean ones that require multiline patterns or use of the hold space, are
what demand engagement of the thinking cap.
I like AWK--I don't hate it. But unless I want to perform arithmetic on
"fields", or require "BEGIN" or "END" blocks, sed gives me all the power
I need in text pattern matching and transformation 99% of the time.
I will concede that a lot of people who maintain sed implementations
other than GNU sed seem to feel about it as you do, and read the POSIX
standard for it, if at all, with deep indifference, which causes many
portability annoyances, some of which I have documented here.
https://cgit.git.savannah.gnu.org/cgit/groff.git/tree/HACKING?h=1.25.0.rc2#n443
The solution is to use a good sed, not one maintained by people who
desperately wish they were doing something else.
> The general feeling is that few people are even aware that "sed" does
> have a programming language in it - and that that (that few people
> know it) is a Good Thing.
No, it's not a good thing. That stance blinds one to the fundamental
definition of what a programming language is.
Reconsider your habit of elevating your personal preferences to
universal hacker wisdom. I've read many of your messages to this list
over the past few years, and find you inadequately equipped to serve as
a fount of expertise. You are free, of course, to say the same of me.
If a person doesn't want to allocate brain cycles to developing
expertise with sed, that's fine. But it's not, of itself, any sort of
exercise of virtue.
Regards,
Branden
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEh3PWHWjjDgcrENwa0Z6cfXEmbc4FAmqPuPAACgkQ0Z6cfXEm bc6DphAAm5MMzEj7lbpwsDQVio4/UksOwImrNNMI49l2RZ38PCEhJ1C/YfABjmTA t/uW3/WvHZ1CdVyxYMoGUNLD292nGt35lPINLm0jbDv9efvUxAzl2UF9+9uYpPOE ZsnZ90Be8vf2Ak+q1IughosrcqYBIP3BI70TLPdZxn7Ndk0oQdnH4gDnU5snz3SM er5slK4S4/6oiPCLpCcLwnHSQar3eTqz15RAhNHmSE9RtkxedwbQKh59d6IEypV0 6bPfQ5aIQs0l1tCw/zgzPHgaKkQ0uGrvhabq2VIavv/UoSNrQK/n7LMqXox6azlQ MXY7Qa9UPMm+PDGGsIdyKus8wn1jIjt22GMN9pyU+82Q4XS9iPSQnbzUKfn3is21 jQnqw55/bQzsafCy+rO6FF1FgIEjD7qDeDBo5tPhL/vMmrucc82ezcvDXp9m0Q6L loP7JE+IAcmumTLdqUuGtu07AOmS0jsHQU54y/FlJu0LIl4Xv7+1k77r1ILqePmU d26RS3mh48qsNBWMvYooDylGqe+NLTBTksMC0cJv/fWUPfFgOJ650Uk0VsCoMZSs mxNmS7mtEfyfXgrUVO6yPvvQju4atAZxja70OpY8+oZuvfJ6FL8fvgrMcOxvkO9F CbUsUubAPzh2xRdLoQxhWpJAdNz00Yh9GDy1nVzbEGpoKTcNAxQ= =Ob31 -----END PGP SIGNATURE-----