"Fossies" - the Fresh Open Source Software Archive

Member "dbtool-1.9.1/samples/locate/locate" (15 May 2015, 383 Bytes) of package /linux/privat/dbtool-1.9.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "locate": 1.9_vs_1.9.1.

    1 #!/bin/sh
    2 #
    3 # simple locate alike
    4 # written as an example how to
    5 # use dbtool.
    6 #
    7 # locate searches the database
    8 # for a file which matches a
    9 # certain string. The parameter
   10 # to locate can be a fully perl-
   11 # compliant regular expression.
   12 #
   13 
   14 db="/var/db/locate.db"
   15 regex=$1
   16 
   17 if test -n "$regex"; then
   18     dbtool -d $db -S -k $regex -w -R
   19 else
   20     echo "Usage: locate <expression>"
   21 fi