Copyright 1984 Michael M Rubenstein Description. I have found a number of programs extremely useful for handling of various text files. Of course, text processing is a common use for micro computers and a number of other programmers have addressed the same problem. Therefore, I found it unnecessary to start from scratch. Most of the programs here were written by others. I have made various modifications -- in some cases very minor, in others extensive -- and have recompiled them using my private run time system. Because the programs were written by several people, there is a variety of programming style represented. I have made no attempt to change the style of the programming except in a few cases in which I found the original intolerable. I have, however, made some modifications to make the user interface reasonably consistent. Except for "sort" (because I felt the memory could be better used for the internal sort), all will now display a program description if invoked with the first parameter "?", e.g. grep ? Common Features. The run time system used for these programs provides a number of useful features. Input and output from the console can be redirected to a file or device. With these programs, redirection of input is seldom much use since a file name may be given on the command line, but redirection of output is often valuable. Redirection of input is accomplished with a parameter of the form filename Whenever a filename is specified (either as a parameter or for redirection), any of the following is also acceptable lst: The CP/M list device rdr: The CP/M reader device pun: The CP/M punch device con: The CP/M console device dum: Dummy -- end of file on input, a sink on output For disk files, the drive and user number may be specified in the "DU" format of ZCPR2. e.g. 8:file File is on user 8 of the current drive b8:file File is on user 8 of the B drive b:file File is on the current user f the B drive File names may also contain one letter flags, specified in brackets ("[]"). To turn flags off, precede them by a hyphen ("-"). To turn on, precede by a plus ("+"). The plus is optional at the beginning of the flags. Examples. lst:[e] (same as lst:[+e]) file.txt[-b+e] Few of the flags are very interesting. The ones you may want to specify are b create a .BAK file if output file already exists. (disk output files only) d delete the file when closed (disk files only. works, but makes no sense for output files) e also echo to the console (all files except con: and dum:) For output files specified as parameters, the b flag is usually assumed, so you may want to turn it off with [-b]. The b flag is never automatically set for redirected output. In all cases, output files may have the same names as input files. The output file will not have that name until it is closed, so that if the program fails (or is interrupted) an old version will not be destroyed. Except for change.com, grep.com, and tr.com, if no output file is specified, the console is used. Those three assume the output is the same as the input. Care must be taken if using these programs on WordStar created files as they clear bit 7, making soft spaces and carriage returns hard. Description of programs. The following gives brief descriptions of the programs. The exact syntax can be obtained with a "?" parameter. change Changes one pattern into another throughout a file. Patterns are the same as those used by grep (below). Note, that the pattern searched for is normally caseless and the pattern to which it is to be changed is assumed to be in lower case unless you use \u. detab Removes tabs from a file. df Compares two text files. entab Inserts tabs where possible in a file. grep General regular expression print. Searches for a pattern in a list of files. This program accepts wild cards. If the pattern contains spaces, it must be enclosed in quotes or apostrophes. This program is very versatile, but may be a bit strange to new users. Therefore, some examples are given here. Put all lines which begin with a tab from file1 into the output in file2 grep -f ^\t file1 >file2 Put all lines which do not begin with an "M" from file1 into file2 grep -f -a ^[^\um] file1 >file2 Show all occurrences of "fprintf" and "sprintf" (but not of "printf" in all c programs on drive b, user 4 grep -a [fs]printf b4:*.c mprint Types several files in columns. Note that by default, if a line from a file does not fit in a column, it will expand the size of the column for that line. sort Fairly general sort for large files. I know the options are a bit confusing, but it can do a lot. One thing to bear in mind -- in quite a few cases speed was sacrificed for versatility. Don't expect this program to win the "sort olympics". split Splits one file into several. Defaults to a round robin method, useful for combining with mprint to get columnar printing. Can also be used simply to break up a file that's gotten too large. tr Translates characters. uniq Removes duplicate lines. wc Counts words, lines, and characters. A very simple algorithm is used (a word is any string of characters surrounded by white space). This is adequate for most purposes. This program takes a list of files. Wild cards are permitted.