bin sh case in 0-1 echo Not enough arguments echo --- echo USAGE held

 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
33
34
#!/bin/sh
case "$#" in
[0-1]) echo "Not enough arguments!"; echo "---"; echo "USAGE: ${0##*/} [held|maxheld|barrier|limit|failcnt] [kmemsize|...]"; exit 1;;
[3-9]) echo "Too many arguments!"; echo "---"; echo "USAGE: ${0##*/} [held|maxheld|barrier|limit|failcnt] [kmemsize|...]"; 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));;
limit)
INDENT=$(($INDENT+5));;
failcnt)
INDENT=$(($INDENT+6));;
*)
;;
esac
/bin/grep $RESOURCE /proc/user_beancounters | /bin/awk -F\ "{print \$$INDENT}"