Hi everyone! Hope you're all having a nice life!
I just bumped into this https://www.oilshell.org/blog/2021/08/xargs.html and thought I'd share it here. An excerpt:
I don't know much about using xargs command, so I find it very interesting, and hope you do too.
I just bumped into this https://www.oilshell.org/blog/2021/08/xargs.html and thought I'd share it here. An excerpt:
What Is xargs?
It's an adapter between text streams and argv arrays, two essential concepts in shell. You pass it flags that specify how to split stdin. Then it generates arguments and invokes processes. Example:
What's happening here?Code:$ echo 'alice bob' | xargs -n 1 -- echo hi hi alice hi bob
- xargs splits the input stream on whitespace, producing 2 arguments, alice and bob.
- We passed -n 1, so xargs then passes each argument to a separate echo hi $ARG command. By default, it passes as many args to a command as possible, like echo hi alice bob.
I don't know much about using xargs command, so I find it very interesting, and hope you do too.