Created
November 4, 2014 15:21
-
-
Save luszczynski/80058b0fc593fa572c86 to your computer and use it in GitHub Desktop.
For - split string
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
# Change IFS according your needs | |
IFS=':' read -a array <<< "$string" | |
# Without index | |
for element in "${array[@]}" | |
do | |
echo "$element" | |
done | |
# With index | |
for index in "${!array[@]}" | |
do | |
echo "$index ${array[index]}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment