I can only remember this because I initially didn’t learn about xargs — so any time I need to loop over something I tend to use forvarin $(cmd) instead of cmd | xargs. It’s more verbose but somewhat more flexible IMHO.
So I run loops a lot on the command line, not just in shell scripts.
I can only remember this because I initially didn’t learn about
xargs
— so any time I need to loop over something I tend to usefor var in $(cmd)
instead ofcmd | xargs
. It’s more verbose but somewhat more flexible IMHO.So I run loops a lot on the command line, not just in shell scripts.