To improve the huge speed impact on find you could simulate something like locate
alias locate="if [ ! -e /tmp/locate.db -a ! -e /tmp/locate.lockdb ]
then touch /tmp/locate.lockdb
trap \"rm /tmp/locate.lockdb; rm /tmp/locate.db; exit\" SIGHUP SIGINT SIGTERM
find /|tee /tmp/locate.db
chmod 666 /tmp/locate.db
elif [ -e /tmp/locate.lockdb ]
then find /
else cat /tmp/locate.db
Of course there is an issue with permissions! It would be better to write some setuid commands for
cat to write the database in super user mode and at a better location but
A cheap alternative on most single or few user systems would be to write a per-user
locate.db somewhere near
Another nice alias is able to update/find. Hmm finally I think this alias works better than the original locate ;)
alias relocate="if [ ! -e /tmp/locate.lockdb ]
then rm /tmp/locate.db
Edit I actually though that relocate should just be used like the locate alias above. If you use the relocate without an argument you get an error. The idea is to use
relocate "no file to search for" if you don't want to search but just update the database.
Ok, the find must be setuid'ed too. But then you can throw away your locate package.
grep argument should be passed through
sed to quote the
NOTE FOR THE NOOBS: When I'm talking about setuid here DON'T SET THE SETUID FLAG ON TOOLS LIKE
find. This would be a security breach of your system! What I mean is to write secure alternatives for these simple commands that work in setuid mode and that work in a restricted way, just for the purpose to provide fitted tools for this alias.