1#!/bin/csh -f 2# 3# Copyright (c) 1989 The Regents of the University of California. 4# All rights reserved. 5# 6# This code is derived from software contributed to Berkeley by 7# James A. Woods. 8# 9# Redistribution and use in source and binary forms are permitted 10# provided that the above copyright notice and this paragraph are 11# duplicated in all such forms and that any documentation, 12# advertising materials, and other materials related to such 13# distribution and use acknowledge that the software was developed 14# by the University of California, Berkeley. The name of the 15# University may not be used to endorse or promote products derived 16# from this software without specific prior written permission. 17# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 18# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 19# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20# 21# @(#)updatedb.csh 4.10 (Berkeley) 08/28/89 22# 23set SRCHPATHS = "/" # directories to be put in the database 24set LIBDIR = /usr/libexec # for subprograms 25if (! $?TMPDIR) set TMPDIR = /var/tmp # for temp files 26set FINDHONCHO = root # for error messages 27set FCODES = /var/db/find.database # the database 28 29set path = ( /bin /usr/bin ) 30set bigrams = $TMPDIR/f.bigrams$$ 31set filelist = $TMPDIR/f.list$$ 32set errs = $TMPDIR/f.errs$$ 33 34# Make a file list and compute common bigrams. 35# Alphabetize '/' before any other char with 'tr'. 36# If the system is very short of sort space, 'bigram' can be made 37# smarter to accumulate common bigrams directly without sorting 38# ('awk', with its associative memory capacity, can do this in several 39# lines, but is too slow, and runs out of string space on small machines). 40 41nice +10 42find ${SRCHPATHS} -print | tr '/' '\001' | \ 43 (sort -f; echo $status > $errs) | \ 44 tr '\001' '/' >$filelist 45$LIBDIR/find.bigram <$filelist | \ 46 (sort; echo $status >> $errs) | uniq -c | sort -nr | \ 47 awk '{ if (NR <= 128) print $2 }' | tr -d '\012' > $bigrams 48 49# code the file list 50 51if { grep -s -v 0 $errs } then 52 echo 'squeeze error: out of sort space' | mail $FINDHONCHO 53else 54 $LIBDIR/find.code $bigrams < $filelist > $FCODES 55 chmod 644 $FCODES 56 rm $bigrams $filelist $errs 57endif 58