# getting command-line options using shell case statement num="" file="" for i # go through command-line args do #echo "$i" case "$i" in #-*) num=$(( - i ));; -[0-9]|-[0-9][0-9]) num=$(( - i ));; -*) echo "bad number $i" 1>&2; exit 1;; #default: *) file="$file $i";; esac done echo "num = $num, file = $file" cat $file # will cat standard input if $file is empty # sample runs: # $ dash case.sh -2 j j # num = 2, file = j j # hi # hi # $ echo something | dash case.sh -6 # num = 6, file = # something # $