I am making a script that needs to loop over a list of files named
like file1, file2, file3, all named the same with the suffix number increasing
according to users input.
So I made thia script, but when I input number 3, she loops only
over file1 and it stops.
Why?
How do I make it loop over n files according to users input?
This is my script:
#!/bin/bash
echo "Base name of machines to bring down:"
read vm
echo "Number of machines:"
read num
COUNTER=0
while [ $COUNTER -lt $num ]; do
num=$[$COUNTER+1]
VBoxManage controlvm $vm$num poweroff
let COUNTER=COUNTER+1
done
use double paren for arithmetic:
Update
I fixed the script so the counter starts at 1 instead of 0. It seems @toninoj wants to start at 1, but in his script, he started at 0.