FWIW AIX also has an apply command https://www.ibm.com/docs/en/aix/7.2?topic=apply-command
An Opinionated Guide to Xargs
81–90 of 135 posts
Re: An Opinionated Guide to Xargs
#82Earlier quoted context omitted.
Some additional tips: 1. You don't need the parentheses. 2. If you use process substitution [1] instead of a pipe, you will stay in the same process and can modify variables of the enclosing scope: i=0 while read -r v; do ... i=$(( i + 1)) done The drawback is that this way `do_something` has to come after `done`, but that's bash for you ¯\_(ツ)_/¯ [1] https://www.gnu.org/software/bash/manual/html_node/Process-S...
Yeah, although I use the parentheses mostly because I like how it reads. And that process substitution trick is important too. I think the redirection can come first, though (not at a computer to test):
Re: An Opinionated Guide to Xargs
#83 cat input.file | ... | while read -r unit; do ${unit}; done | ...
between 'while read -r unit' and 'while IFS= read -r unit' I can probably handle 90% of the cases. (maybe I should always use IFS since I tend to forget the proper way to use it).Re: An Opinionated Guide to Xargs
#84Re: An Opinionated Guide to Xargs
#85Re: An Opinionated Guide to Xargs
#86I tend to reach for gnu parallel instead of xargs - https://www.gnu.org/software/parallel/parallel_alternatives.... parallel is probably on the complex side but its also been actively developed, bugfixed and had a lot of road miles from large computing users.
The nagware prompts of parallel are so objectionable that I will do a lot of things to avoid using it at all. So pretentious!
Re: An Opinionated Guide to Xargs
#87Earlier quoted context omitted.
I've been thinking about titles, and it's hard to make a good one that doesn't look like a total cliché. "X considered harmful", "an opinionated guide to X", some kind of joke or reference, what could be a collection of tags (X, Y and Z), "things I have learned doing X", etc.
I specifically clicked on this topic because of the word “opinionated”. As I already know how to use xargs, I was curious what kind of non-conventional or controversial opinion the author might have.
Re: An Opinionated Guide to Xargs
#88FWIW AIX also has an apply command https://www.ibm.com/docs/en/aix/7.2?topic=apply-command
I spent a year using AIX at my previous job and never heard of this or saw anybody use it. Is it new in 7.2? We were far behind on AIX 6.
Re: An Opinionated Guide to Xargs
#89Since the blog author is commenting here, you have this statement part way down your blog: > That is, grep doesn't support an analogous -0 flag. However, the GNU grep variant does have an analogous flag: -z, --null-data Treat the input as a set of lines, each terminated by a zero byte (the ASCII NUL character) instead of a newline. Like the -Z or --null option, this option can be used with commands like sort -z to pr…
Ah cool, I didn't know that! I'll update the blog post. (What a cacophony of flags) Edit: It seems that grep -0 isn't taken for something else and they should have used it for consistency? The man page says it's meant to be used with find -print0, xargs -0, perl -0, and sort -z (another inconsistency)