Using wildcard inside case statement in bash -


i'm making simple bash script. accepts 2 options (-d , -f). allow long version of options (-directory , -file). tried using curly brackets wildcard doesn't work. suggestions?

thanks!

#!/bin/bash  while test $# != 0   case $1 in   -f)     #     ;;   {-d,-directory})     #     ;;   *)     echo "error"     ;;   esac   shift done 

use pipe symbol:

case $1 in     -f)         #         ;;     -d|-directory)         #         ;;     *)         echo "error"         ;;  esac 

the various options within case statement shell script patterns, pattern can several patterns separated pipe symbol |. can use regular expressions in pattern, example

-[dd]|-directory) 

would match both -d, -d , -directory.


Comments