Android and Linux

Sunday, May 23, 2010

locate.sh

I polished and uploaded my locate script to L.E.S. Linux. It can be found in L.E.S. under the name "locate.sh" or here:
#! /system/bin/sh

if test -z "$1"; then exec echo "USAGE: locate.sh [filename|-u|--help]"; fi

case "$1" in
--help)
echo 'locate.sh by fubaya (a-more-common-hades.blogspot.com)
This is a cheap imitation of the UNIX locate command. It stores
a list of all the files on your system to /sdcard/.locatedb (about 2MB)
then greps that file to find whatever you are looking for.

USAGE: locate.sh [filename|-u|--help]

[filename] case insensitive search for any file of any type.

-u update the "database." This must be ran periodically if you want to
find new files. I have it set to run at boot on phone.

--help display this help message

EXAMPLE: $ cd /; touch /data/testfile
$ locate.sh testfile
$
$ locate.sh -u
database updated
$
$ locate.sh testfile
/data/testfile
$
'
;;
-u)
find / -print > /sdcard/.locatedb && echo "database updated"
;;
*)
grep -i "$1" /sdcard/.locatedb
;;
esac


Copy locate.sh to your clipboard with this QR code:

Followers