home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
UTILITYS
/
FIND.ARC
/
FIND.DOC
< prev
Wrap
Text File
|
1990-07-21
|
4KB
|
114 lines
The FIND utility has been in the public domain in various
forms for some years now. This version is one of the best,
approaching GREP in power while being reasonably quick in
operation and small in code size. It can also handle squeezed
files.
FIND searches (squeezed or plain) text files for things. You
tell it the names of the files you want to search and what you
want to look for, e.g.
find *.m?c [hl|de],({?})
The above invocation of find will search all the .MAC (and
.MQC) files for lines containing "hl" or "de" followed by a
comma and something in parentheses.
~
FIND expects two arguments on the command line. The first
tells FIND the name(s) of the files you want to search, the
second tells it what to look for. FIND scans each of the
files trying to match the text therein with the pattern
represented by the second argument. Searching is done on a
line-by-line basis.
A simple form of the FIND command might be:
find *.c? putc
This tells FIND to scan all the .C (and .CQ) files in the
current disk and user area looking for the string "putc".
FIND will report the name of each file it scans and will
display any line containing the pattern "putc". It is not
sensitive to case; lines containing "putc", "Putc" and "PUTC"
will be displayed, as will lines containing "putch", "fputc"
and so on.
~
You can tell FIND to search for more than one thing at a time.
For example, you might want to find all references to BDOS and
BIOS in a group of assembly-language files. You could use the
command:
find *.a?m [bios|bdos]
Note the | character used to separate alternative patterns and
the brackets used to enclose them. Another way to do the same
thing would be:
find *.a?m b[i|d]os
which says "look for a 'b' followed by an 'i' or a 'd'
followed in turn by 'os'.
~
FIND recognises certain meta-characters in search patterns. A
question mark in a pattern matches any character in the text
of a file. The commands
find *.a?m b?os and find *.a?m b[i|d]os
are similar; the second restricts matching to the strings
"bios" and "bdos" in the text whereas the first would also
report lines containing things like "Ambrosia" and "caboose".
The meta-characters recognised by FIND are:
? any character
@ any alphanumeric
_ tab (the '_' is an underscore)
~
Finally, things within a search pattern can be enclosed in
braces. This tells FIND to match zero or more occurrences of
the {pattern} in the text. For example,
find *.doc 1{0}.
would match lines containing a 1 followed by any number of
zeros followed by a decimal point. You may recall the example
at the beginning of these notes contained the following within
the search pattern:
({?})
which means "a left parenthesis followed by any number of
arbitrary characters followed by a right parenthesis".
~
You can get pretty clever at specifying search patterns but
there are some simple rules which are worth noting.
1. It is faster to search for more than one thing at a time
than to do multiple searches.
2. If you are not really sure what you are looking for then
err on the side of ambiguity. You may get a lot of
spurios lines displayed but at least you get the ones in
which you are interested, e.g. "ms{-}dos" rather than
"msdos" or "ms-dos".
3. Keep the search patterns as short as possible. It speeds
up the search, e.g. "fri" rather than "friday".
~
At any time a Control-C terminates the program. When scanning
multiple files pressing any other key skips to the next file
(if any).
If you use the FIND command with no parameters then you get a
screenful of information which is a highly abbreviated form of
these notes.
These notes were prepared by
John Hastwell-Batten,
SYSOP, Tesseract RCPM+,
P.O. Box 242,
Dural, NSW 2158,
Australia.