Setting the record straight on SunOS 4.0 'fastfind'
david at sun.com
david at sun.com
Fri Jan 13 19:31:50 AEST 1989
In article <12397 at silica.BBN.COM> mlandau at bbn.com (Matt Landau) writes:
>Updatedb only works on type 4.2 filesystems, so you have to run it on each
>of you servers, and it only builds a cache for 4.2 filesystems, so you
>have to do "find string" on each server to find all instances of what
>you're looking for.
Well, not really. Updatedb is a (pretty simple) shell script and you can
make it do whatever you want. For example, I have a diskful workstation
but my home directory is on a server. Here's the updatedb I use; I only
run it once a week, but actually it isn't that big a load on the server...
#!/bin/csh -f
#
# @(#)updatedb.csh 1.1 86/07/08 SMI; from UCB 4.6 85/04/22
#
set SRCHPATHS = ( / /usr ) # directories to be put in the database
set EXCLUDE = '^/tmp|^/dev|^/usr/tmp' # directories to exclude
set NFSPATHS = ~david # NFS directories
set NFSUSER = daemon # userid for NFS find
set LIBDIR = /usr/lib/find # for subprograms
set FINDHONCHO = root # for error messages
set FCODES = $LIBDIR/find.codes # the database
set path = ( $LIBDIR /usr/ucb /bin /usr/bin )
set bigrams = /tmp/f.bigrams$$
set filelist = /tmp/f.list$$
set errs = /tmp/f.errs$$
# Make a file list and compute common bigrams.
# Alphabetize '/' before any other char with 'tr'.
# If the system is very short of sort space, 'bigram' can be made
# smarter to accumulate common bigrams directly without sorting
# ('awk', with its associative memory capacity, can do this in several
# lines, but is too slow, and runs out of string space on small machines).
nice +6
( find ${SRCHPATHS} -xdev -print ; \
su $NFSUSER -c "find ${NFSPATHS} -xdev -print" -f ) | \
egrep -v "$EXCLUDE" | \
tr '/' '\001' | \
(sort -f; echo $status > $errs) | \
tr '\001' '/' > $filelist
$LIBDIR/bigram <$filelist | \
(sort; echo $status >> $errs) | uniq -c | sort -nr | \
awk '{ if (NR <= 128) print $2 }' | tr -d '\012' > $bigrams
if { grep -s -v 0 $errs } then
echo "Subject: updatedb failed on `hostname`" | \
/bin/mail $FINDHONCHO
exit 1
endif
# code the file list
$LIBDIR/code $bigrams < $filelist > $FCODES
chmod 644 $FCODES
rm -f $bigrams $filelist $errs
exit 0
--
David DiGiacomo, Sun Microsystems, Mt. View, CA sun!david david at sun.com
More information about the Comp.sys.sun
mailing list