Skip to content

Instantly share code, notes, and snippets.

@punund
Created November 24, 2011 00:16
Show Gist options
  • Save punund/1390324 to your computer and use it in GitHub Desktop.
Save punund/1390324 to your computer and use it in GitHub Desktop.
splitter in bash
#!/bin/bash
[[ $1 =~ ([[:alnum:]]+)-([[:alnum:]]+) ]] || exit 1
[[ "$2" = suffix ]] &&
echo ${BASH_REMATCH[2]} && exit 0
echo ${BASH_REMATCH[1]} && exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment