Insert 1000+ nodes and attributes with XMLStarlet - Running Slow
Why not use parallel (or sem) so that you can parallelise the job over the number of cores available on the machine?The code I use is parsing an array with 2 variables, that I export in local just to make sure processes are isolated.
for array in "${listofarrays[@]}"; do local var1;local var2 IFS=, read var1 var2 <<< $array sem -j +0 <code goes here>donesem --wait
unbuffer might help
unbuffer from the expect package
to build a pipe from two commands a, z
unbuffer a | z
to build a pipe from three (or more) commands a, b, z
add the -p option inside the pipe
unbuffer a | unbuffer -p b | z
source: stolen from stackexchange