Skip to content

Instantly share code, notes, and snippets.

@luszczynski
Created November 4, 2014 15:21
Show Gist options
  • Save luszczynski/80058b0fc593fa572c86 to your computer and use it in GitHub Desktop.
Save luszczynski/80058b0fc593fa572c86 to your computer and use it in GitHub Desktop.
For - split string
# 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