home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-User.iso / usr / lib / find / updatedb < prev   
Text File  |  1990-01-22  |  1KB  |  41 lines

  1. #!/bin/csh -f
  2. #
  3. #     @(#)updatedb.csh    1.3 88/05/08 4.0NFSSRC SMI; from UCB 4.6 85/04/22
  4. #                   @(#) from SUN 1.4
  5. #
  6. #
  7. set SRCHPATHS = "/"            # directories to be put in the database
  8. set LIBDIR = /usr/lib/find        # for subprograms
  9. set FINDHONCHO = root            # for error messages
  10. set FCODES = /etc/find.codes        # the database 
  11.  
  12. set path = ( $LIBDIR /usr/ucb /bin /usr/bin )
  13. set bigrams = /tmp/f.bigrams$$
  14. set filelist = /tmp/f.list$$
  15. set errs = /tmp/f.errs$$
  16.  
  17. # Make a file list and compute common bigrams.
  18. # Alphabetize '/' before any other char with 'tr'.
  19. # If the system is very short of sort space, 'bigram' can be made
  20. # smarter to accumulate common bigrams directly without sorting
  21. # ('awk', with its associative memory capacity, can do this in several
  22. # lines, but is too slow, and runs out of string space on small machines).
  23.  
  24. nice +10
  25. find ${SRCHPATHS} -fstype nfs -prune -o -print | tr '/' '\001' | \
  26.    (sort -f; echo $status > $errs) | \
  27.    tr '\001' '/' >$filelist
  28. $LIBDIR/bigram <$filelist | \
  29.    (sort; echo $status >> $errs) | uniq -c | sort -nr | \
  30.    awk '{ if (NR <= 128) print $2 }' | tr -d '\012' > $bigrams
  31.  
  32. # code the file list
  33.  
  34. if { grep -s -v 0 $errs } then
  35.     echo 'squeeze error: out of sort space' | mail $FINDHONCHO
  36. else
  37.     $LIBDIR/code $bigrams < $filelist > $FCODES
  38.     chmod 644 $FCODES
  39.     rm $bigrams $filelist $errs
  40. endif
  41.