#!/bin/sh -u # Demonstrate the TEST command in an IF statement (numeric test). # For a list of numeric comparison operators, see the "test" man page. # -IAN! idallen@idallen.ca # Shell variable $# contains the count of arguments to this shell script. # Since $# isn't a very mnemonic name, copy the count to a better name. # argcount=$# # Set a maximum and minimum argument count. # MAX=4 MIN=2 # Compare against $MIN # if test $argcount -lt $MIN ; then echo "argument count $argcount is less than than $MIN" else echo "argument count $argcount is not less than $MIN" fi # Compare against $MAX # if test $argcount -ge $MAX ; then echo "argument count $argcount is greater than or equal to $MAX" else echo "argument count $argcount is less than $MAX" fi