Duyên Trương
New member
How do you increment a counter in a bash script?
Answer
counter=$((counter+1)) – this is how you can increment a counter. The $ for counter is optional inside the double parentheses in this case. elif [[ “$counter” -gt 20 ]]; then – this checks whether $counter is not greater than 20 . If so, it outputs the appropriate message and breaks out of your while loop.
Answer
counter=$((counter+1)) – this is how you can increment a counter. The $ for counter is optional inside the double parentheses in this case. elif [[ “$counter” -gt 20 ]]; then – this checks whether $counter is not greater than 20 . If so, it outputs the appropriate message and breaks out of your while loop.