#!/bin/sh -u # # $0 pathname # # A script that identifies if the file given on the command line is empty. # Nonexistent and non-files are ignored. # # WARNING: Many of the comments in this file are "Instructor-Type" # comments and are *not* appropriate for real scripts. Do not put # "Instructor-Type" comments into the scripts that you submit for marking. # I put them in my example files because I am teaching you how to # write scripts; do not submit my teaching comments back to me again. # Read the week7.txt notes for more details on good comment style. # # -IAN! idallen@ncf.ca June 2001 # All scripts must start with lines similar to these two: # export PATH=/bin:/usr/bin umask 022 # Validate the script arguments. # Output what the extra arguments were, to help the user. # if [ "$#" -ne 1 ]; then echo 1>&2 "$0: Expecting exactly one argument; found $# ($*)" exit 1 fi # We only process existing files and ignore otherwise. # if [ ! -f "$1" ]; then echo 1>&2 "$0: Argument '$1' is not an existing file name" exit 1 fi # At this point in the script, we know the file exists. # We only check if it is not empty (has non-zero size). # if [ -s "$1" ]; then echo "'$1' is not empty" else echo "'$1' is empty" fi exit 0