{"p":"","h":{"iv":"ROXSYW+cfvEbFHu5","at":"ocxplSQjdRC3tXEtB/9/wg=="}}

after 25 years of using the command line... it's probably time I learn how `xargs` works huh

22
Share
Share on Mastodon
Share on Twitter
Share on Facebook
Share on Linkedin
Aaron Huslage

@darius I mean it is an advanced topic.

0
2y
mcc

@darius Can't hurt, but I've "learned" this at least 3 times and it's always easier to write a perl oneliner with `` than it is to figure out which xargs arguments count in the current situation.

1
2y
Darius Kazemi

a 2000 word `man` page, a lifetime to master

3
2y
alive

@darius i just pipe things into xargs and pass some random flags that seem nice hope for the best either it'll do exactly what i want or it'll delete everything — an exciting mystery!

0
2y
Kee Hinckley

@darius I’m at 40+ years of not using xargs. I think last month was only the second time where I decided it was worth figuring out (and then forgetting) the options. “find” and that weird “{} \;”, otoh, is embedded in my fingers.

1
2y
⛭ eiríkr ⛭

@darius my tip is to use `xargs echo cmd` instead of `xargs cmd` so you can play around and see what would happen. less intimidating if you aren't worried about fucking up.

1
2y
elle mundy

@darius xargs is the sound i make when i have to use xargs

0
2y
Nelson Minar

@darius the -0 flag is a real lifesaver (combined with find -print0).

GNU parallel has been a useful tool for me in the past, too.

0
2y
Kilian Evang

@darius I use GNU Parallel instead. It can run things in parallel but more fundamentally, it's xargs with a much better CLI.

0
2y
Bill Hunt

@darius I cover it briefly in my article on unix tools, I mainly use it when I need to pass arguments around to multiple calls but am too lazy to write a full shell script for capturing output: billhunt.dev/blog/2015/05/10/u

0
2y
Richard

@darius It always takes me more time to figure out how to use it than it saves in processing time. But still worth it just for the joy of seeing parallel stuff happen, and the excitement of wondering if it will complete ok.

0
2y
plambrechtsen

@darius regex before xargs

0
2y
Trammell Hudson

@darius I'm "scared to use spaces in filenames" old, so I recommend always "find -print0 | xargs -0" just in case there are any surprises

1
2y
1
2y
Anthony Sorace

@darius I hate it. Half of the common usage feels like compensating for shells with bad quoting rules or subprocess capabilities.

0
2y
botvolution

@darius I literally only finally learned last year, and I won't say it changed my life, and I still don't understand -0 but it's one of those niche things that is occasionally just a neat, elegant solution to a niggly cli problem

0
2y
slut respecter

@darius xargs is simpler than it appears, and incredibly useful. i recommend also checking out gnu parallel

0
2y
Eli the Bearded

@darius I find I rarely need it. Between shell looping and non-dumb use of find, not much need.

find dir args -exec prog {} \; # dumb one at a time
find dir ars -print0 | xargs -0 prog {} # tedious so much typing
find dir args -exec prog {} + # nice, no xargs needed

for thing in $(find dir args) ; do
# handy loop, but $IFS sensitive
done

0
2y
Glyph

@darius if you need xargs you should *probably* be using a general purpose programming language

0
2y
EMi

@darius Meanwhile, I will NOT learn how it works but I will pronounce it in a very silly way out loud while my puppy gives me a weird look

1
2y
Replies