Skip to content

Instantly share code, notes, and snippets.

@DinosaurDad
Created December 18, 2013 19:44
Show Gist options
  • Save DinosaurDad/8028573 to your computer and use it in GitHub Desktop.
Save DinosaurDad/8028573 to your computer and use it in GitHub Desktop.
Split a value into multiple variables in a shell script. Orginally available on StackOverflow: http://stackoverflow.com/a/10520718/464827
STR=foo-bar
var1=${STR%-*}
var2=${STR#*-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment