bin sh case in 0-1 echo Not enough arguments echo USAGE ARG1 ARG2 exit

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
case "$#" in
[0-1]) echo "Not enough arguments"; echo "USAGE: ${0##*/} ARG1 ARG2"; exit 1;;
[3-9]) echo "Too many arguments"; echo "USAGE: ${0##*/} ARG1 ARG2"; exit 1;;
*) ;;
esac
TYPE="$1"
RESOURCE="$2"
case "$RESOURCE" in
kmemsize)
INDENT=1;;
*)
INDENT=0;;
esac
case "$TYPE" in
held)
INDENT=$(($INDENT+2));;
maxheld)
INDENT=$(($INDENT+3));;
barrier)
INDENT=$(($INDENT+4));;
failcnt)
INDENT=$(($INDENT+6));;
*)
;;
esac
/bin/grep $RESOURCE /proc/user_beancounters | /bin/awk -F\ "{print \$$INDENT}"