Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created January 10, 2014 16:28
Show Gist options
  • Select an option

  • Save coderofsalvation/8357468 to your computer and use it in GitHub Desktop.

Select an option

Save coderofsalvation/8357468 to your computer and use it in GitHub Desktop.
explodes string to array based on given delimiter
# explodes string to array based on given delimiter
# @param string delimitor
# @param string varname
# @param string input
# usage: explode "," myarray "foo,bar"
# echo ${myarray[@]}
explode(){
IFS="$1" read -a $2 <<< "$3"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment