Debian Codegraph @

ex39.sh

raw symbols SCIP
1 #!/bin/bash
2
3 ROOT_UID=0 # Only users with $UID 0 have root privileges.
4 E_NOTROOT=65
5 E_NOPARAMS=66
6
7 if [ "$UID" -ne "$ROOT_UID" ]
8 then
9 echo "Must be root to run this script."
10 # "Run along kid, it's past your bedtime."
11 exit $E_NOTROOT
12 fi
13
14 if [ -z "$1" ]
15 then
16 echo "Usage: `basename $0` find-string"
17 exit $E_NOPARAMS
18 fi
19
20
21 echo "Updating 'locate' database..."
22 echo "This may take a while."
23 updatedb /usr & # Must be run as root.
24
25 wait
26 # Don't run the rest of the script until 'updatedb' finished.
27 # You want the the database updated before looking up the file name.
28
29 locate $1
30
31 # Without the 'wait' command, in the worse case scenario,
32 #+ the script would exit while 'updatedb' was still running,
33 #+ leaving it as an orphan process.
34
35 exit 0