[comp.sys.tandy] GREP-like utility for the Model 4

7gmadiso@pomona.bitnet.UUCP (04/06/87)

GREP - Global Regular Expression Printer.
Model 4 - TRSDOS 6.2.x - Written February, 1987 by Mark Tabas, Denver, CO.

GREP is fashioned after the UNIX System V grep utility. It is used to search
text files for patterns. My grep supports the relevant options of the UNIX
grep. However, UNIX shell metacharacters cannot be supported (without
rewriting the UNIX shell) so my grep allows only for literal string searches.
The usage of grep is as follows:

grep  -vcnyp| expression filename

The options produce the following effects:

  -v   All lines but those matching are printed.
  -c   Only a count of lines matching is printed.
  -n   Each line is displayed by its line number in the file.
  -y   Causes the string search to be case independent.
  -p   Causes output to be sent to the line printer.

More than one option may be simultaneously to create the desired string
search algorithm. For example:

grep -vc mom letter/txt:1

...will display only a count of all lines not containing the string "mom" in
the file letter/txt:1. Whenever the -c option is used, printing of lines is
supressed.

While this program was written in assembly to minimize search time, its speed
is directly related to disk speed. When using a floppy drive, the average
search time of a 75K file is 10 seconds. Using hard disks and ramdisks, I was
able to decrease sort time moderately. Grep is around 1K in length and uses
another 2K data buffer. Thus, during runtime it occupies memory starting at
&HF000 and ending around &HFC00. If this is unnaceptable for your
application, you may obtain the source code and reassemble it to the desired
location in memory.

Finally, this program is pure PUBLIC DOMAIN. Since the selling of software is
immoral and evil, I ask nothing for this work. Feel free to distribute it as
you wish. Any questions regarding this program or requests for source code,
may be directed to me on Incubus BBS - 609.881.0969  sysop - Chuck Diem.

Mark Tabas
Denver, Colorado.