home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / conf / inall < prev    next >
Text File  |  1994-08-17  |  382b  |  32 lines

  1. #! /bin/sh
  2. # run a command in each of several directories
  3.  
  4. cmd="$1"
  5. shift
  6. case $# in
  7. 0)    echo "Usage: $0 cmd dir ..." >&2 ; exit 2    ;;
  8. esac
  9. for d
  10. do
  11.     if test ! -d $d
  12.     then
  13.         echo "$0: \`$d' is not a directory" >&2
  14.         exit 1
  15.     fi
  16. done
  17.  
  18. here=`pwd`
  19. for d
  20. do
  21.     echo "==== $d:" >&2
  22.     cd $here/$d
  23.     eval $cmd
  24.     if test $? -ne 0
  25.     then
  26.         echo "*** $0 terminated" >&2
  27.         exit 1
  28.     fi
  29.     echo
  30. done
  31. exit 0
  32.