
Xargs Should Be In Your Command Line Toolbag DistroTube
video description
Date: 2022-03-30
Related videos
Comments and reviews: 10
Guy
This is really useful! I made a script that processed several million files, output from the find command using -print0 and xargs with the -0 argument (for using paths / filenames with spaces) and launching another script, 16 of them in parallel with -n1 and -P16 arguments to xargs. The performance was phenomenal: the Dual Xeon E5-2660v2 (2 x 8 cores) usage was up to 95%, averaging about 80%. This is multi-threading bash scripting!
reply
This is really useful! I made a script that processed several million files, output from the find command using -print0 and xargs with the -0 argument (for using paths / filenames with spaces) and launching another script, 16 of them in parallel with -n1 and -P16 arguments to xargs. The performance was phenomenal: the Dual Xeon E5-2660v2 (2 x 8 cores) usage was up to 95%, averaging about 80%. This is multi-threading bash scripting!
reply
Rocket89
I see you too use ToS. Would be great for us financial dilettantes to see your setup! (do it in a paperMoney account to hide your GME investments from the YT interwebs :P ). Would be interested how you have that all set up with your wm & terminal, if you have any scripts/python/julia/haskell stuff running to help analyze companies, markets, etc. Thanks for the great content!
reply
I see you too use ToS. Would be great for us financial dilettantes to see your setup! (do it in a paperMoney account to hide your GME investments from the YT interwebs :P ). Would be interested how you have that all set up with your wm & terminal, if you have any scripts/python/julia/haskell stuff running to help analyze companies, markets, etc. Thanks for the great content!
reply
Peter
The main reason why xargs exists is that the length of the command line used to be quite limited (back in the days) - 8k characters. A find with -exec rm -- quickly exceed that limit. Though, you could increase the size it was more convenient to use xargs. However, for the examples you've shown (like echo ...) it makes more sense to me to use e.g. -echo $(ls)-.
reply
The main reason why xargs exists is that the length of the command line used to be quite limited (back in the days) - 8k characters. A find with -exec rm -- quickly exceed that limit. Though, you could increase the size it was more convenient to use xargs. However, for the examples you've shown (like echo ...) it makes more sense to me to use e.g. -echo $(ls)-.
reply
Jonathon
Your system does not seem to understand alphabetical order? it places single character numbers after everything else. For example (498, 499, 4).
Waa really confused about how it should possible screw up that much, but it seems like Linux really just does not care about extensions very much? which seems to be the only way it could screw up this colossally.
reply
Your system does not seem to understand alphabetical order? it places single character numbers after everything else. For example (498, 499, 4).
Waa really confused about how it should possible screw up that much, but it seems like Linux really just does not care about extensions very much? which seems to be the only way it could screw up this colossally.
reply
Maxi
I always used subshells, like (ls -l -a -h) = (ls -echo --l -a -h--) = (ls $(echo --l -a -h-)) = etc.
At 1:08 that would be (command2 -command1-) or (command2 $(command1))
But yeah xargs is way nicer, because otherwise you would end up in bracket hell at some point XD
reply
I always used subshells, like (ls -l -a -h) = (ls -echo --l -a -h--) = (ls $(echo --l -a -h-)) = etc.
At 1:08 that would be (command2 -command1-) or (command2 $(command1))
But yeah xargs is way nicer, because otherwise you would end up in bracket hell at some point XD
reply
ozzman530
I use -a option to read from a file of hosts, and xargs can ping every host in the file. Using the -P option lets me ping multiple hosts at a time, and I can find the status of hundreds of hosts in a matter of seconds using ping. Good for identifying network problems.
reply
I use -a option to read from a file of hosts, and xargs can ping every host in the file. Using the -P option lets me ping multiple hosts at a time, and I can find the status of hundreds of hosts in a matter of seconds using ping. Good for identifying network problems.
reply
daniel
I am currently having a subject in university, which is focused on bash but they don't really teach us the commands. They simply mention them and expect us to be able to work with them from the start. Even as a Linux user, I find it hard. Your videos are a life saver
reply
I am currently having a subject in university, which is focused on bash but they don't really teach us the commands. They simply mention them and expect us to be able to work with them from the start. Even as a Linux user, I find it hard. Your videos are a life saver
reply
Sundarapandian
I never knew about xargs command, I get basic xargs like behavior by using $() in bash. For example I'll do -echo $(seq 5)- to get the sequence in the same line. Advanced replacements like --I- option you showed is going to be very useful. Thanks.
reply
I never knew about xargs command, I get basic xargs like behavior by using $() in bash. For example I'll do -echo $(seq 5)- to get the sequence in the same line. Advanced replacements like --I- option you showed is going to be very useful. Thanks.
reply
Archisha
Hey! This was very helpful, lucid and comprehensive.
I wanted to ask .. how do we set the time taken to be displayed once a process is executed - Like it showed - took 5s- for you. Please do make a video for the same.
Thanks in advance!
reply
Hey! This was very helpful, lucid and comprehensive.
I wanted to ask .. how do we set the time taken to be displayed once a process is executed - Like it showed - took 5s- for you. Please do make a video for the same.
Thanks in advance!
reply
Arjen
one very important advantage for -exec vs xargs is when there are spaces in the filenames. That completely messes up xargs, but works fine with -exec. This is why I've made it a habit of always using -exec
reply
one very important advantage for -exec vs xargs is when there are spaces in the filenames. That completely messes up xargs, but works fine with -exec. This is why I've made it a habit of always using -exec
reply
Add a review, comment
Other channel videos















