date and time created 83/07/21 00:15:12 by mckusick
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Thu, 21 Jul 1983 15:15:12 +0000 (07:15 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Thu, 21 Jul 1983 15:15:12 +0000 (07:15 -0800)
SCCS-vsn: usr.bin/locate/locate/updatedb.csh 4.1

usr/src/usr.bin/locate/locate/updatedb.csh [new file with mode: 0644]

diff --git a/usr/src/usr.bin/locate/locate/updatedb.csh b/usr/src/usr.bin/locate/locate/updatedb.csh
new file mode 100644 (file)
index 0000000..bf827ca
--- /dev/null
@@ -0,0 +1,35 @@
+#! /bin/sh
+#
+#      @(#)updatedb.csh        4.1     (Berkeley)      83/07/21
+#
+set LIBDIR = /usr/lib/find     # for subprograms
+set FINDHONCHO = root          # for error messages
+set FCODES = /etc/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 +10
+find / -print | tr '/' '\001' | \
+   (sort -f; echo $status > $errs) | \
+   tr '\001' '/' | tee $filelist | $LIBDIR/bigram | \
+   (sort; echo $status >> $errs) | uniq -c | sort -nr | \
+   awk '{ if (NR <= 128) print $2 }' | tr -d '\012' > $bigrams
+
+# code the file list
+
+if { grep -s -v 0 $errs } then
+       echo 'squeeze error: out of sort space' | mail $FINDHONCHO
+else
+       $LIBDIR/code $bigrams < $filelist > $FCODES
+       rm $bigrams $filelist $errs
+endif