home *** CD-ROM | disk | FTP | other *** search
/ norge.freeshell.org (192.94.73.8) / 192.94.73.8.tar / 192.94.73.8 / pub / computers / 3b2 / rmjunk < prev    next >
Text File  |  1985-07-02  |  752b  |  35 lines

  1. #    @(#)rmjunk    1.2    /sccs/src/cmd/sadmin/shell/s.rmjunk
  2. #    remove files of dubious worth
  3. #    Removes all files that match the patterns listed in the filelist file
  4. #    starting at <starting-directory> (default /)
  5. #    that are more than <days> old (default 4).
  6.  
  7. #!    chmod +x ${file}
  8.  
  9. if [ $# -lt 1 ]
  10. then
  11.     echo >&2 "Usage:  $0 filelist [ starting-directory ] [ days ]"
  12.     exit 1
  13. fi
  14.  
  15. #    generate list of -name arguments for find
  16. if [ ! -r $1 ]
  17. then
  18.     echo >&2 "$0:  cannot read file '$1'"
  19.     exit 1
  20. fi
  21. names=`sed -n '    /^#/d
  22.         s/[     ]\{1,\}#.*//
  23.         /^[     ]*$/d
  24.      '"    /./ s/.*/-o -name '&'/p
  25.      "  $1  |
  26.     sed '1s/-o //'`
  27. if [ -z "${names}" ]
  28. then
  29.     echo >&2 "$0:  no file names!"
  30.     exit 1
  31. fi
  32.  
  33. eval find ${2:-/} -type f -atime +${3:-4} '\(' ${names} '\)' \
  34.     -print -exec rm {} '\;'
  35.