1#!/bin/csh -f 2# 3# Copyright (c) 1989, 1993 4# The Regents of the University of California. All rights reserved. 5# 6# This code is derived from software contributed to Berkeley by 7# James A. Woods. 8# 9# %sccs.include.redist.sh% 10# 11# @(#)updatedb.csh 8.4 (Berkeley) 10/27/94 12# 13 14set SRCHPATHS = "/" # directories to be put in the database 15set LIBDIR = /usr/libexec # for subprograms 16 # for temp files 17if (! $?TMPDIR) setenv TMPDIR /var/tmp 18set FCODES = /var/db/locate.database # the database 19 20set path = ( /bin /usr/bin ) 21set bigrams = $TMPDIR/locate.bigrams.$$ 22set filelist = $TMPDIR/locate.list.$$ 23set errs = $TMPDIR/locate.errs.$$ 24 25# Make a file list and compute common bigrams. 26# Alphabetize '/' before any other char with 'tr'. 27# If the system is very short of sort space, 'bigram' can be made 28# smarter to accumulate common bigrams directly without sorting 29# ('awk', with its associative memory capacity, can do this in several 30# lines, but is too slow, and runs out of string space on small machines). 31 32# search locally or everything 33# find ${SRCHPATHS} -print | \ 34find ${SRCHPATHS} \! -fstype local -prune -or -print | \ 35 tr '/' '\001' | \ 36 (sort -T $TMPDIR -f; echo $status > $errs) | tr '\001' '/' > $filelist 37 38$LIBDIR/locate.bigram < $filelist | \ 39 (sort -T /$TMPDIR; echo $status >> $errs) | \ 40 uniq -c | sort -T /$TMPDIR -nr | \ 41 awk '{ if (NR <= 128) print $2 }' | tr -d '\012' > $bigrams 42 43# code the file list 44 45if { grep -s -v 0 $errs } then 46 printf 'locate: updatedb failed\n\n' 47else 48 $LIBDIR/locate.code $bigrams < $filelist > $FCODES 49 chmod 644 $FCODES 50 rm $bigrams $filelist $errs 51endif 52