invoke bash functions in xargs
MapReduce multiple lines of input into segregated input, Recently I keen to use it to tackle with many situation that need to use a bash loop.
But I find I could not pass parameters to
xargs if I want to invoke functions in it.
This may happen if you need functional programming, but xargs could hardly achieve it at a glance.
You can not invoke functions that defined in same file with
xargs command because after retrieving the
xargs could not got this function.
What you need to do is to register this function, or just
export -f it.
Just as comments explains in script, use
export -f to export a bash function.
bash -c functionName to invoke this function in
I reckon it will be much popular and hacky to use
xargs in the future.
Hard to imagine how the ancient
UNIX engineers figure out it! It is fabulous!