#!/bin/sh -u # $0 [filenames...] # # From the command line arguments, select only arguments that are # readable file names. (Print warnings and skip over non-files or # unreadable arguments.) Output one line per file in this format: # # $ ./foo one . two .. nosuch # The file 'one' contains 27 lines. # Ignored non-file '.'. # The file 'two' contains 123 lines. # Ignored non-file '..'. # Ignored non-file 'nosuch'. # # 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 export PATH=/bin:/usr/bin umask 022 # This loop iterates over all the command line arguments. # for arg do if test -f "$arg" ; then if test -r "$arg" ; then echo "The file '$arg' contains $(wc -l <"$arg") lines." else echo "Ignored unreadable file '$arg'." fi else echo "Ignored non-file '$arg'." fi done