
FIND, Copyright © 1989, by Larry Phillips.

This program may be freely distributed, in its entirety only,
including updatedb, find, and find.doc.  No chage may be made for
this program beyond a reasonable media charge. It may be distributed
on any public or private BBS or telecommunication service, provided
there are no extra charges for downloading, beyond normal connect
time fees.

If you use find, and like it, if it saves you time, or if you have
comments, criticisms or a wish list, please send me a postcard from
where you live. Consider the cost of the postcard and stamp a
shareware fee. If I could include the card and stamp in the
distribution, I would.

Send to:

    Larry Phillips
    3575 E. 28th Ave.
    Vancouver, BC, Canada
    V5R 1T4

-------------------------------------------------------------

UPDATEDB:  creates the files used by find
---------

  Updatedb will create a file called 'find.codes' in a directory
called 'FindDB:'.  It will take a while, so don't panic (it takes
about 4 1/2 minutes on my setup, but the time taken will depend
entirely on how many directories and files you are catalogging).  The
file created will only match the actual contents of your partitions
until you save, delete, or move files around, but it is a simple
matter to run updatedb once a day (more or less, depending on your
disk activity, and how long you can remember the changes you make on
your disks).

Syntax: updatedb [ [-v] dhn: dhn: ...]

   dhn:  device name.

    -v:  verbose mode. This is a debuggin feature for updatedb, in
         case you have a problem with a partition or filename. It
         will show you which directory it was working on when it
         failed. The directory names are sent to the screen,
         delimited with vertical bars ('|'), in a different colour.
         The -v option is used only when entering the partition names
         on a command line.

Examples:  updatedb            ; take arguments from FindDB:find.config
           updatedb dh0: dh1:  ; catalog dh0: and dh1:
           updatedb -v dh1:    ; catalog dh1:, verbose.

If you specify partitions on the command line, they will be used to
generate the find.codes file.  If you don't specify partitions,
updatedb will look for a file in your 'FindDB:' directory called
'find.config'.  This file should have _only_ one line in it,
consisting of the partitions you want to include in the catalog,
separated by spaces.  In either case, the last partition named in
'find.config' or on the command line will be the first one processed,
so you should put them in order of least likely to most likely to be
searched.

updatedb may be stopped by typing a CTRL C. It will stop after
processing the directory it is working on.


find.codes:  This is a straightforward file, consisting of directory
names and file names, separated by NULL bytes.  (hex 00).  Directory
names will always end with a colon (':') or a slash ('/').  The order
is as follows:

dirname/ NULL filename NULL filename NULL dirname/ NULL filename NULL ...

            =================================

FIND:  find files and directories on hard disk
-----  

  Find  uses a database file called 'find.codes', to quickly find any
  directory or file.  These two files are created by the companion
  program 'updatedb'.

  Output from the program may be halted at any time by pressing
  CTRL C. I debated a long time on where to check for the CTRL C, for
  speed considerations,and finally decided to check only when a match
  was detected, and right after the directory search.  This means
  that the directory will be completely searched if there are no
  matches. It ends pretty quickly anyway (see comments on speed
  below).

Syntax: find [-e] string

  string :  the string to match.  Without the '-e' argument, the
            string need only be contained in the directory or file
            entry.  For example, the string 'game' will match
            'game', 'games', or 'endgames'.  See '-e' below for
            exact matches.

      -e :  Optional, [E]xact.  Matches directories and filenames
            only if the string argument matches exactly.  For
            example, the argument 'game' will not match a directory
            or file named 'games'

      -d :  Only match on directory names.

      -f :  Only match on file names

      -v :  Verbose. Show a header for directories and one for files.

   The above flags can be combined in any way. The only one that doesn't
   make sense if using -f and d ( -fd ) at the same time. Since the
   function of these flags is exclusionary in nature, you are excluding
   files and directories.

            =================================

Setting it up
-------------

  Find and updatedb contain a few 'hardwired' assumptions.

  The first assumption:  I have an assigned directory called 'FindDB:'
You can set up a directory like this, and make the assignment, or if
you wish to have your find files elsewhere, use a file zapper to
change the path/filename in both programs.  I welcome suggestions on
how best to set up the configurability.

  The second assumption is only in updatedb, and that is that if no
command line arguments are given, it looks for them in
'FindDB:find.config'

            =================================

Everyday usage:
---------------

  I usually run updatedb once per day, either before going to bed or
before going to work.  It would be a good candidate for putting in a
crontab to run at some time you will not be using the machine.

  Find is extremely fast, especially when compared with searching a
disk with DIR or LIST.  If I invoke it with a string that I know will
not be found (eliminating screen output time), it will do a complete
search in between 2 and 7 seconds, depending on the length of the
pattern searched for (longer patterns take less time).  Before you
groan and tell me that isn't fast, let me tell you about my find
files and disk partitions...

My FindDB:find.codes is 133351 bytes long, consisting of 1174
directory entries and over 10,000 file entries

  If you are anything like me, you forget where things are, and
waste a lot of time looking for them.  On my current setup, it would
take me over 5 minutes to do a 'dir all' of all partitions, and more
time still to search the output for the file I want.  The disk space
overhead in having the find files is quite small.

  Now for 2.0, the new output format of find allows you to do some very
things. The 2.0 AmigaShell has what is known as 'backtick' capability.
This allows you to use the backtick character (the character below the
tilde, to the left of the '1' key), to surround a command, and to use the
results as input to the command itself, just as if you had typed the
arguments in. Here ara couple of examples. First, using standard Amigados
commands...

First, the search command..

    search #?.(c|h) MyFunction nonum quiet

The above command will show you the names of all files in the current
directory, ending in .c or .h, that contain the string 'myfunc'. Now you
can combine it with another command, such as list...

    list `search #?.(c|h) MyFunction nonum quiet`

In this command, the files are searched, just as in the search used alone,
but the results are sent to 'list' to be used as command arguments, and all
the files containing 'myfunc' will be listed.

Find is one of the handiest programs to use in this manner. If you always
call temporary files by the same name, such as 'junk' or 'foo' or 'tmp',
and if you know that you do not have any files containing worthwhile info
that are called by those names, you can get rid of them all in one command.

	delete `find -fe junk`

Another possibility... you have a number of files scattered around the disk
that are really the same file, but you only ant to keep the most recent one.
Rather than looking all over and hoping you don't miss any, you can use find.
Beter, you can use find in a backtick to list them, allowing you to see the
date...

   list `find -fe macros.asm`

Perhaps you want to edit the files. Assume you are using CEDPro...

   ed `find -fe macros.asm`

  The possibilities are endless. 


            =================================

Enjoy!

Larry Phillips: CIS -  76703,4322
                Usenet - lphillips@lpami.wimsey.bc.ca
                      or uunet!van-bc!lpami!lphillips
