Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: the splits
On Wed, May 22, 2024, at 5:36 PM, Ray Andrews wrote:
> Of course. Yes, different tools for different jobs. What I meant was
> that it terms of priority awk might have given me more bang for the
> buck as the first tool to learn. Mind, sed is simpler and that's why I
> went that way.
Yes, it's quite common -- borderline universal -- to start with sed
and pick up awk later.
> Tx. for links. 'Strength reduction' is something I
> believe in instinctively. I always want to do things in native zsh
> code if possible. External tools have to justify their weight.
You take this way too far, in my opinion. Compared to appropriate
external tools, zsh-heavy solutions often perform poorly and are
more difficult to understand and maintain. (Compare your original
code to the awk solutions Mark and Roman offered.) Most of your
code would improve if you (judiciously) used more external utilities
and less zsh.
(For example, when you find yourself doing this:
output=$(cmd)
lines=(${(f)output})
for line in $lines
do
modify_line_and_print_it
done
you should step back and consider ''cmd | sed'' or ''cmd | awk''
instead, especially if cmd might output more than a couple of
lines.)
--
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author