#!/bin/sh -u # # $0 [ args... ] # # A script that word counts its arguments and lists them in reverse # sorted order. If given no arguments, it operates on STDIN (just as do # most Unix commands!). # # 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 # Jun 12 2001 # All scripts must start with lines similar to these two: # export PATH=/bin:/usr/bin umask 022 # The "$@" syntax is treated specially by the Shell - see the text. # Note how the error message is written to Standard Error using "1>&2". # The error message includes the name of this script, the command exit # status, and the arguments that caused the error. # Only the status of last command in a pipeline is available; errors # seen by "wc" will not be detected. (This is unfortunate, since it # is "wc" that will detect 99% of the errors in the arguments!) # if wc "$@" | sort -nr ; then status=0 # it worked else status=$? # save the bad status return code echo 1>&2 "$0: The sort of '$*' didn't work: status $status" fi exit $status