Add it after the command you want to run in the background:
for drive in "${hddletter[@]}"
do
printf '%s: %s\n' "$drive" "$(perform_hdparm "$drive")" &
done
wait
Question
Trying to execute a function with an &
so the For Loop will continue to execute without waiting for the job to be done.
My Function
perform_hdparm() {
hdparm -t "$1" | awk '/seconds/{print $11}'}
The For Loop
for drive in ${hddletter[@]}; do
printf '%s: %s\n' "$drive" "$(perform_hdparm "$drive")"
The Array contains
/dev/sda /dev/sdb /dev/sdk
So where do I put the &
at to make things continue or can I? Just trying to speed things up.
Thank you
La solution
Add it after the command you want to run in the background:
for drive in "${hddletter[@]}"
do
printf '%s: %s\n' "$drive" "$(perform_hdparm "$drive")" &
done
wait