bash script loop through two variables in lock step

#!/bin/bash
a=(sd fd dir)
b=(storage file director)
for k in "${!a[@]}"
do
   echo "restarting bacula ${b[k]} daemon"
   /sbin/service "bacula-${a[k]}" restart
   echo
done

Leave a Comment