Is there any more efficient way to do the following in zsh?
I imagine that there might be ways to get rid of the intermediate array parameters a
and/or b
.
The script gets some output from a command. If that output is not empty, it skips the first two lines, then it uses as arguments for another command the text before the first space on each of the remaining lines.
#!/usr/bin/env zsh packages=$(pip3 list -o) if [[ -n ${packages} ]]; then print "${packages}" a=("${(f)packages}") b=("${a[@]:2}") PYTHONWARNINGS=ignore:DEPRECATION pip3 install -U "${b[@]%% *}" fi