#!/bin/sh -ux # Demonstrate the many uses of the built-in TEST command # Reference: Chapter 11 # This script runs in "debug" mode (see the -x above) # -IAN! idallen@ncf.ca test 3 -gt 5 echo $? [ 3 -lt 5 ] echo $? test dog = cat echo $? [ dog = dog ] echo $? test -f /etc/passwd echo $? [ -d /etc/passwd ] echo $? [ -f /etc ] echo $? test -d /etc echo $? [ -r /etc/passwd ] echo $? [ -w /etc/passwd ] echo $? [ -x /etc/passwd ] echo $? rm -f emptyfile.txt [ -e emptyfile.txt ] echo $? touch emptyfile.txt [ -s emptyfile.txt ] echo $? rm emptyfile.txt date >notempty.txt [ -s notempty.txt ] echo $? if [ -s notempty.txt ] ; then echo "File is not empty." fi if test -s notempty.txt ; then echo "File is not empty." fi rm notempty.txt