Rexx Utilities


The following are brief descriptions of each of the Rexx utility programs contained in jrexutil.zip (23K). All of these programs were written for use under OS/2, but unless otherwise noted below it should be a simple matter to adapt them to work under other operating systems (provided there`s a Rexx interpreter/compiler available.) All of these programs are covered by the GNU General Public License.

after.cmd

This program takes a date and a directory and/or file name as arguments and searches the specified directory and all of its subdirectories for files whose names match the given file name (which may contain wildcards) and were last modified on or after the specified date. The full path name of each of these files, prefixed with the date on which it was last modified, is output.

The part of this program that does the actual search for files is specific to OS/2, but the rest should be fairly generic.

This program isn`t terribly millennium compliant, but that`s due to the fact that OS/2 Rexx function used to search for the files (SysFileTree) only returns the last two years of the file`s date.

calc.cmd

This is a simple little program that allows you to do basic math at the command line. It only understands Rexx expressions, but these are almost always the same as regular mathematical expressions.

drop.cmd

This filter outputs all but the first n lines of its input, where n is specified as an argument. So for example
   type afile.txt | drop 10
will output all but the first 10 lines of afile.txt to the standard output. Thus nothing would be output if afile.txt contained fewer than 10 lines.

This program is based on the CMS Pipelines stage of the same name, though it doesn`t support the FIRST and LAST options. Also see the take.cmd program below.

edit.cmd

This is a very simple Rexx script to launch the OS/2 EPM editor from the command line so that it is maximized and such that the command line can be used while the editor is running. Needless to say, it is very OS/2-specific.

locate.cmd

This filter outputs only those lines of its input that contain the specified search string in the specified column range. The search is case sensitive, and the column range is optional.

As an example,

   locate 1.2 -/*- < rexxfile.cmd
will output those lines of rexxfile.cmd that start with the Rexx opening comment symbol (/*).

This program is based on the CMS Pipelines stage of the same name, though it doesn`t support multiple column ranges or empty search strings. Also see the nlocate.cmd program below.

nlocate.cmd

This filter outputs only those lines of its input that do not contain the specified search string in the specified column range. The search is case sensitive, and the column range is optional.

As an example,

   nlocate 1.2 -/*- < rexxfile.cmd
will output those lines of rexxfile.cmd that do not start with the Rexx opening comment symbol (/*).

This program is based on the CMS Pipelines stage of the same name, though it doesn`t support multiple column ranges or empty search strings. Also see the locate.cmd program above.

rexx.cmd

A simple but occasionally handy little program that lets you enter and execute Rexx statements at the command line. For example,
   rexx do i = 1 to 10; say random(1, 6); end
will print out ten random numbers each between 1 and 6 inclusive.

This is basically just a very simple version of the REXXTRY program that comes with most Rexx distributions.

scp.cmd

Another simple Rexx script. This one copies all of the C and C++ source files in the current directory to a specified directory.

Though it comes configured to back up C and C++ files, it can be modified to copy other types of files just by changing the copyPatterns string, which contains the file patterns of the files to back up.

The command that does the actual copying is specific to DOS/Win/OS/2, but there should be an equivalent command on just about every other platform.

take.cmd

This filter outputs the first n lines of its input, where n is specified as an argument. So for example
   type afile.txt | take 5
will output the first 5 lines of afile.txt to the standard output. If afile.txt has 5 lines or fewer then the entire file would be output.

This program is based on the CMS Pipelines stage of the same name, though it doesn`t support the FIRST and LAST options. Also see the drop.cmd program above.


Author: James MacKay
Last Updated: July 22, 1997
Copyright © 1997 James MacKay