Created
August 20, 2015 17:16
-
-
Save indraniel/403f4b81a1a55d31d837 to your computer and use it in GitHub Desktop.
A C-style loop iteration in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -a arr=("echo 'hi'" "echo 'hello'") | |
for (( i = 0; i < ${#arr[@]} ; i++ )); do | |
printf "\n**** Running: ${arr[$i]} *****\n\n" | |
# Run each command in array | |
eval "${arr[$i]}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment