#! /bin/bash

ALLFILES=~/tmp/allfiles
if test ! -d ~/tmp
then
    mkdir ~/tmp
fi
TMPFILES=/tmp/$$.allfiles

TR=/usr/bin/tr
SED=/bin/sed
FIND=find
GREP="fgrep -i"
MV=/bin/mv

if test $# = 0
then # create new file
    # look at LOCation DIRectorieS, or $HOME
    if test "$LOCDIRS"
    then
        LOCDIRS=`echo $LOCDIRS | $TR ':' ' '`
    else
        LOCDIRS=$HOME
    fi
    # search the directories
    for root in $LOCDIRS
    do
        prefix=`echo $root | $TR '/' '@'`
        $FIND $root -print |
            $TR '/' '@' |
                $SED s/^$prefix// |
                    $TR '@' '/' >> $TMPFILES
    done
    #compress $TMPFILES
    $MV -i $TMPFILES $ALLFILES
else
    $GREP $1 < $ALLFILES
fi
chmod 600 $ALLFILES

