Skip to content

Instantly share code, notes, and snippets.

@shkumagai
Created May 14, 2012 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shkumagai/2694512 to your computer and use it in GitHub Desktop.
Save shkumagai/2694512 to your computer and use it in GitHub Desktop.
Can I use regex in case expression?
#!/bin/sh
case $1 in
[1-9])
echo "Less than 10: $1"
;;
[1-9][0-9])
echo "Greater than equal 10, and Less than 100: $1"
;;
*)
echo "Greater than equal 100 or not integer: $1"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment