#!/bin/sh -u # Perform several tests on the first argument to this script. # Reference: Chapter 11 # If no arguments, do the tests on /etc/passwd instead. # More file-testing operations by the TEST command in an IF statement # For a larger list of file-testing operators used by TEST, see p.372 # -IAN! idallen@ncf.ca # First, find out which pathname we are going to be testing. # if [ $# -ge 1 ] ; then # use first argument as pathname (ignores other arguments) path="$1" else # use a default because first argument is missing path="/etc/passwd" fi echo "You are using pathname '$path'." if [ -d "$path" ] ; then echo "The path '$path' is a directory" else echo "The path '$path' is missing or is not a directory" fi if [ ! -w "$path" ] ; then echo "The path '$path' is missing or is not writable" else echo "The path '$path' is writable" fi if [ ! -x "$path" ] ; then echo "The path '$path' is missing or is not executable" else echo "The path '$path' is executable" fi