I'm trying to write a bash script that loops through two variables:
#!/bin/bash
for i in sd fd dir && j in storage file director
do
echo "restarting bacula $j daemon"
/sbin/service bacula-$i restart
echo
done
The code above is obviously wrong. But I want i & j to move in lock step with one another. Can someone help me with a way to achieve this?
Thanks
#!/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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With