home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 345.lha / Find_v3.9c / Find.doc < prev    next >
Encoding:
Text File  |  1990-01-29  |  8.5 KB  |  217 lines

  1. NAME
  2.            find (this doc for v3.9c)
  3.  
  4. SYNOPSIS
  5.            find -[acgsv] <root dir> <pattern>
  6.  
  7. FUNCTION
  8.            Searches a directory and its subdirectories for the pattern
  9.  
  10. INPUTS
  11.            -[acgsv]     Options (see below)
  12.            <root dir>   Any valid AmigaDos directory name
  13.            <pattern>    A (very) restricted regular expression
  14.  
  15. RESULTS
  16.            Displays the name(s) found on standard output, and maybe more
  17.            depending on the options invoked
  18.  
  19. KNOWN BUGS
  20.            With option -g, the prompt doesn't seem to be updated if you
  21.            are using Conman or WShell. However, there is no problem with
  22.            standard NewCon windows
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.                                 Find
  33.                                 ----
  34.  
  35. November, 21st 1989                                  Author: Cedric BEUST
  36.  
  37. * A few lines to describe how it works
  38. --------------------------------------
  39.  
  40.     In fact, I did my best so that my command does not need any
  41. documentation to be used. This is due to the fact that I bothered a lot
  42. when I tried to master the CLI for the first time since no documentation at
  43. all was available at this time (ugh! Looks like prehistoric age!). I DO
  44. THINK that any command should be self-explanatory. Commodore programmers,
  45. do you hear me?
  46.  
  47.     All right, I said what I had to, so let's come to it.
  48.  
  49.     The initial idea was to have a Unix-like find command on Amiga. This
  50. has never been supplied by Commodore and I have always wondered why.
  51. Recently, I decided that I had wondered enough and I started programming
  52. it. The result is far from having all the Unix' find possibilities, but
  53. though, it helped me a lot (anyway, Unix' one has a lot of features which
  54. nobody never uses. Commodore's ones as well).
  55.  
  56.      If you type 'find' with nothing at all, or with wrong parameters or
  57. with a '?', you'll get the following lines (approximately):
  58.  
  59.   Find (v3.9c) - Recursive search of files
  60.   Copyright Cedric BEUST - NICE (France)
  61.  
  62. Usage: find -[acgv] <source dir> <pattern>
  63.  
  64.     Options:
  65.  
  66.             -a:  Don't stop at first occurence
  67.             -c:  Don't ignore case
  68.             -g:  Change to directory found
  69.             -s:  Stop as soon as something is found
  70.             -v:  Display search steps
  71.  
  72.  Wildcards: ? (any character), # (none or several times) and * (anything)
  73.  To abort search, type CTRL-C
  74.  
  75.      Isn't all that self-explanatory? As a matter of fact, it is. But yet,
  76. I will add a few things.
  77.  
  78.  
  79. * Syntax
  80. --------
  81.  
  82.   - The options
  83.  
  84.       So far, there are five options:
  85.  
  86.       -a:
  87.          Means that when a file is found, find doesn't stop and keeps on
  88.          searching until it has searched all the directories. This is
  89.          useful if you know that the name you are searching might be found
  90.          in several directories. NOTE: this option is automatically set if
  91.          you use a pattern. The reason why I did this is simple: if you
  92.          use a pattern, then you can't tell whether the first name that
  93.          will appear is the one you are looking for or not. And you
  94.          wouldn't like the program to stop at this point, would you?
  95.       -c:
  96.          By default, find will ignore letter case, i.e.
  97.              find jh0: test
  98.          will either match 'test' (of course!), 'Test', 'TESt', and so on.
  99.          With the -c flag on, only 'test' will be found.
  100.       -g:
  101.          This feature is especially useful in scripts. It makes a CD to the
  102.          found directory. This allows to do something to the name found
  103.          after it has been found (for example,  deleting it). For instance,
  104.          using it with the -s flag could produce a little shell script that
  105.          might delete all the hated .fastdir throughout your hard disk.
  106.          Good idea, isn't it?
  107.       -v:
  108.          This is for your eye's pleasure! It merely displays the          
  109.          directories it is scanning with an indentation in order to get   
  110.          an idea of the hierarchy of the disk searched (and also to prove 
  111.          that it is well doing what you expect!).
  112.       -s:
  113.          This one forces find to stop after the      
  114.          first name found, bypassing what I said a few lines above. You   
  115.          will surely object that this option is redundant with the -a     
  116.          one, but I don't think so and I have a good reason for that.     
  117.          Suppose you want to write a script that deletes all the .fastdir 
  118.          on your hard disk (the idea is not mine but Cedric's. Yes,
  119.          another one). You use a 'find -g jh0: .fastdir' and as soon as
  120.          it is found, you delete it and you loop. OK. But suppose you want  
  121.          to delete a pattern... For example, all the .bak. Then, you have   
  122.          to force find to stop after each occurence it gets. That's what     
  123.          the -s option does. On the opposite, suppose that by default,
  124.          find stops ALWAYS as soon as it finds something, and suppose
  125.          there is an option to force it to continue. Will you always think
  126.          to use this option when looking for a pattern? I don't think I
  127.          will. So I prefer this solution.
  128.  
  129.    - The source dir
  130.          No need to write long about that. Any device name will do, even     
  131.          an 'assign'ed one (jh0:, df0:, mydir:, jh2:lib, etc...). This will
  132.          be the root directory, and find will then scan all its directories
  133.          and subdirectories.
  134.  
  135.    - The pattern
  136.          It may be a simple name or a pattern. This pattern follows
  137.          AmigaDos' weird conventions about this: # and ? are accepted.
  138.          I also provide the * wildcard which is a synonymous for #?. Use
  139.          the ones you prefer (but ( ) and | are not yet implemented. If
  140.          you often use these ones, let me know so that I know if it's worth
  141.          adding them). Has anyone out there ever used the # character with
  142.          something else than '?'? So why bother with this notation? Anyway,
  143.          I decided to stick to it since I'd like my command to have its
  144.          place in any c: directory. Let's see a few examples of pattern
  145.          matching:
  146.  
  147.           a?c   -->  abc acc adc...
  148.           a#bc  -->  ac abc abbc abbbc...
  149.           a#?.c -->  a.c asadf.c aer.c...
  150.           *.s   -->  myprog.s .s foo.S (if -c option not turned on)
  151.  
  152.        You see? I'll stop with these examples but I'm quite confident that
  153.        my pattern matching routine will work correctly even in the worst
  154.        cases (believe me, I've tested it quite a bit!). Anyway, I found
  155.        out that I rarely use something else than the ones I just
  156.        described.
  157.  
  158.   A CTRL-C may be used at any time to abort search. I bet you'll find this
  159. feature useful when find is entering the depths of your directory and it
  160. has already given you the name you were looking for!
  161.  
  162.  
  163. * One last thing
  164. ----------------
  165.  
  166.   And this one deserves a special chapter since it is not said in the help
  167. menu (nobody is perfect! But don't criticize or I'll add it in next
  168. versions): if ever find couldn't find any file matching the pattern, it
  169. will send a return code of 5 (it is a WARN code). This is useful in
  170. scripts to know when find is finished with its work: all you have to do is
  171. to include a 'IF WARN SKIP END ELSE...' and it will not loop forever.
  172.  
  173.  
  174. :-)
  175.   Well! Looks like I wrote a bit more than what I thought. And yet, it is
  176. a soooo short command! There will be probably other versions, depending on
  177. the suggestions I am made (this is for YOU!). But I can already announce
  178. that there will probably be a Workbench version of this function (alike
  179. Mac's one). But this will take much more work to do and will depend on the
  180. number of requests I receive about it.
  181.  
  182.   A few thanks to all the ones who helped me improve this command and add
  183. new options, and mainly:
  184.  
  185. - Cedric Nerot
  186.     Guru proof thorough testing and the .fastdir application program
  187. - Jean-Charles Godien
  188.     Special thanks to him! Nifty pattern matching routine, JC!
  189. - Pierre Ardichvili
  190.     Sharp-witted suggestions
  191. - Bruce Lepper
  192.     Alpha, beta, gamma, ... and other-greek-letters versions tester
  193.     despite him
  194. - Henry J. Cobb
  195.     For his precious advice regarding the prompt bug with the -g option
  196.  
  197.                         Enjoy!
  198.  
  199.  
  200. You can send me your suggestions to this address:
  201.  
  202.       BEUST  Cedric
  203.        "Promethee"
  204. 80 Av. du Bois de Cythere
  205.        06000 NICE
  206.          FRANCE
  207.     Tel. 93 96 00 23
  208.  
  209.  
  210. These ones are likely to change, but one of them at least should last
  211. until summer 1990 (precise your mail is for C. BEUST)
  212.  
  213.         gnu@cerisi.cerisi.fr        (try this one first)
  214.         olch@geocub.greco-prog.fr
  215.         laurent2@cerisi.cerisi.fr
  216.         beust@malibu.archipel.fr    (not yet reachable as I am writing)
  217.