Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!cornell!uw-beaver!rice!sun-spots-request From: david@sun.com Newsgroups: comp.sys.sun Subject: Re: Setting the record straight on SunOS 4.0 'fastfind' Message-ID: <8901052012.AA21976@david.sun.com> Date: 13 Jan 89 09:31:50 GMT References: <2359@kalliope.rice.edu> <12397@silica.BBN.COM> Sender: usenet@rice.edu Organization: Sun-Spots Lines: 62 Approved: Sun-Spots@rice.edu Original-Date: Thu, 5 Jan 89 12:12:03 PST X-Sun-Spots-Digest: Volume 7, Issue 100, message 5 of 11 In article <12397@silica.BBN.COM> mlandau@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@sun.com