i have a while loop reading lines from a $hosts
while read line
do
ip=$line
check
done < $hosts
my question is can I us
You can start multiple processes, each calling the function check
and wait for them to finish.
while read line
do
ip=$line
check &
done < $hosts
wait # wait for all child processes to finish
Whether this increases the speed depends on available processors and the function check
's implementation. You have to ensure there's no data dependency in check
between iterations.