Last active
December 11, 2015 13:38
-
-
Save ksykulev/4608420 to your computer and use it in GitHub Desktop.
Delimited String to Array
This file contains hidden or 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 | |
str="[email protected];[email protected];[email protected]" | |
delimiter=";" | |
declare -a arr | |
arr=(`echo ${str//$delimiter/ }`) | |
#get "keys" - ${!arr[@]} | |
for i in "${!arr[@]}"; do | |
printf "%s\t%s\n" "$i" "${arr[$i]}" | |
done | |
#0 [email protected] | |
#1 [email protected] | |
#2 [email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment