home *** CD-ROM | disk | FTP | other *** search
- NAME
- find (this doc for v3.9c)
-
- SYNOPSIS
- find -[acgsv] <root dir> <pattern>
-
- FUNCTION
- Searches a directory and its subdirectories for the pattern
-
- INPUTS
- -[acgsv] Options (see below)
- <root dir> Any valid AmigaDos directory name
- <pattern> A (very) restricted regular expression
-
- RESULTS
- Displays the name(s) found on standard output, and maybe more
- depending on the options invoked
-
- KNOWN BUGS
- With option -g, the prompt doesn't seem to be updated if you
- are using Conman or WShell. However, there is no problem with
- standard NewCon windows
-
-
-
-
-
-
-
-
-
- Find
- ----
-
- November, 21st 1989 Author: Cedric BEUST
-
- * A few lines to describe how it works
- --------------------------------------
-
- In fact, I did my best so that my command does not need any
- documentation to be used. This is due to the fact that I bothered a lot
- when I tried to master the CLI for the first time since no documentation at
- all was available at this time (ugh! Looks like prehistoric age!). I DO
- THINK that any command should be self-explanatory. Commodore programmers,
- do you hear me?
-
- All right, I said what I had to, so let's come to it.
-
- The initial idea was to have a Unix-like find command on Amiga. This
- has never been supplied by Commodore and I have always wondered why.
- Recently, I decided that I had wondered enough and I started programming
- it. The result is far from having all the Unix' find possibilities, but
- though, it helped me a lot (anyway, Unix' one has a lot of features which
- nobody never uses. Commodore's ones as well).
-
- If you type 'find' with nothing at all, or with wrong parameters or
- with a '?', you'll get the following lines (approximately):
-
- Find (v3.9c) - Recursive search of files
- Copyright Cedric BEUST - NICE (France)
-
- Usage: find -[acgv] <source dir> <pattern>
-
- Options:
-
- -a: Don't stop at first occurence
- -c: Don't ignore case
- -g: Change to directory found
- -s: Stop as soon as something is found
- -v: Display search steps
-
- Wildcards: ? (any character), # (none or several times) and * (anything)
- To abort search, type CTRL-C
-
- Isn't all that self-explanatory? As a matter of fact, it is. But yet,
- I will add a few things.
-
-
- * Syntax
- --------
-
- - The options
-
- So far, there are five options:
-
- -a:
- Means that when a file is found, find doesn't stop and keeps on
- searching until it has searched all the directories. This is
- useful if you know that the name you are searching might be found
- in several directories. NOTE: this option is automatically set if
- you use a pattern. The reason why I did this is simple: if you
- use a pattern, then you can't tell whether the first name that
- will appear is the one you are looking for or not. And you
- wouldn't like the program to stop at this point, would you?
- -c:
- By default, find will ignore letter case, i.e.
- find jh0: test
- will either match 'test' (of course!), 'Test', 'TESt', and so on.
- With the -c flag on, only 'test' will be found.
- -g:
- This feature is especially useful in scripts. It makes a CD to the
- found directory. This allows to do something to the name found
- after it has been found (for example, deleting it). For instance,
- using it with the -s flag could produce a little shell script that
- might delete all the hated .fastdir throughout your hard disk.
- Good idea, isn't it?
- -v:
- This is for your eye's pleasure! It merely displays the
- directories it is scanning with an indentation in order to get
- an idea of the hierarchy of the disk searched (and also to prove
- that it is well doing what you expect!).
- -s:
- This one forces find to stop after the
- first name found, bypassing what I said a few lines above. You
- will surely object that this option is redundant with the -a
- one, but I don't think so and I have a good reason for that.
- Suppose you want to write a script that deletes all the .fastdir
- on your hard disk (the idea is not mine but Cedric's. Yes,
- another one). You use a 'find -g jh0: .fastdir' and as soon as
- it is found, you delete it and you loop. OK. But suppose you want
- to delete a pattern... For example, all the .bak. Then, you have
- to force find to stop after each occurence it gets. That's what
- the -s option does. On the opposite, suppose that by default,
- find stops ALWAYS as soon as it finds something, and suppose
- there is an option to force it to continue. Will you always think
- to use this option when looking for a pattern? I don't think I
- will. So I prefer this solution.
-
- - The source dir
- No need to write long about that. Any device name will do, even
- an 'assign'ed one (jh0:, df0:, mydir:, jh2:lib, etc...). This will
- be the root directory, and find will then scan all its directories
- and subdirectories.
-
- - The pattern
- It may be a simple name or a pattern. This pattern follows
- AmigaDos' weird conventions about this: # and ? are accepted.
- I also provide the * wildcard which is a synonymous for #?. Use
- the ones you prefer (but ( ) and | are not yet implemented. If
- you often use these ones, let me know so that I know if it's worth
- adding them). Has anyone out there ever used the # character with
- something else than '?'? So why bother with this notation? Anyway,
- I decided to stick to it since I'd like my command to have its
- place in any c: directory. Let's see a few examples of pattern
- matching:
-
- a?c --> abc acc adc...
- a#bc --> ac abc abbc abbbc...
- a#?.c --> a.c asadf.c aer.c...
- *.s --> myprog.s .s foo.S (if -c option not turned on)
-
- You see? I'll stop with these examples but I'm quite confident that
- my pattern matching routine will work correctly even in the worst
- cases (believe me, I've tested it quite a bit!). Anyway, I found
- out that I rarely use something else than the ones I just
- described.
-
- A CTRL-C may be used at any time to abort search. I bet you'll find this
- feature useful when find is entering the depths of your directory and it
- has already given you the name you were looking for!
-
-
- * One last thing
- ----------------
-
- And this one deserves a special chapter since it is not said in the help
- menu (nobody is perfect! But don't criticize or I'll add it in next
- versions): if ever find couldn't find any file matching the pattern, it
- will send a return code of 5 (it is a WARN code). This is useful in
- scripts to know when find is finished with its work: all you have to do is
- to include a 'IF WARN SKIP END ELSE...' and it will not loop forever.
-
-
- :-)
- Well! Looks like I wrote a bit more than what I thought. And yet, it is
- a soooo short command! There will be probably other versions, depending on
- the suggestions I am made (this is for YOU!). But I can already announce
- that there will probably be a Workbench version of this function (alike
- Mac's one). But this will take much more work to do and will depend on the
- number of requests I receive about it.
-
- A few thanks to all the ones who helped me improve this command and add
- new options, and mainly:
-
- - Cedric Nerot
- Guru proof thorough testing and the .fastdir application program
- - Jean-Charles Godien
- Special thanks to him! Nifty pattern matching routine, JC!
- - Pierre Ardichvili
- Sharp-witted suggestions
- - Bruce Lepper
- Alpha, beta, gamma, ... and other-greek-letters versions tester
- despite him
- - Henry J. Cobb
- For his precious advice regarding the prompt bug with the -g option
-
- Enjoy!
-
-
- You can send me your suggestions to this address:
-
- BEUST Cedric
- "Promethee"
- 80 Av. du Bois de Cythere
- 06000 NICE
- FRANCE
- Tel. 93 96 00 23
-
-
- These ones are likely to change, but one of them at least should last
- until summer 1990 (precise your mail is for C. BEUST)
-
- gnu@cerisi.cerisi.fr (try this one first)
- olch@geocub.greco-prog.fr
- laurent2@cerisi.cerisi.fr
- beust@malibu.archipel.fr (not yet reachable as I am writing)
-