use xargs to replace bash loop
I have no solution toward multi-options dealing command, When I come across this, I will have a bash script to achieve it.
But now, I find a ancient but marvel tool in linux called xargs.
By using xargs, I could skip the loop in bash for many situations.
1 | |
The bash script shown above is what I used to do when I need to batchly dealing with folder files. But now, I could do it with only one line command:
1 | |
Wow, how briliant is it, which save a lot of time and energy on writing and meditating bash structure.
But actually there can be more usefulness by ultilizing xargs, for instance in find command, you can implement complex command in just one line, instead of using bash looping.
1 | |
More usage about the xargs, please refer to man xargs.
use xargs to replace bash loop
https://rug.al/2014/2014-01-12-use-xargs-to-replace-bash-loop/