Short: AREXX for first/last/both ends of a file Author: Herbert Wollman hwollman@mitre.org Uploader: Herbert Wollman hwollman mitre org Type: util/cli Requires: util/libs/rexxarplib.library Architecture: m68k-amigaos Distribution: All Heads.doc Documentation for head, tail, and ends 3 AREXX programs for viewing the first/last/both ends of a file. Herbert Wollman, Telephone (617) 272-2994 5 Fowler Ter, Burlington, MA 01803, USA. E-mail at hwollman@mitre.org Head and tail are handy utilities for viewing the first and last lines respectively of files. They are a standard part of any UNIX computer, and have been ported to many other computer systems. Their default behavior is to copy the first (or last, respectively) 10 lines from Standard Input to Standard Output. However, like most UNIX commands, command line options can make them much more versatile. The usage is, head [ -LineCount ] [ File ] [ OtherFiles... ] tail [ -LineCount ] [ File ] [ OtherFiles... ] ends [ -LineCount ] [ File ] [ OtherFiles... ] If the first command line parameter is a negative integer, it will specify the number of lines copied. If the LineCount parameter is missing, it will default to 10. Any other parameters are the names of files to read instead of Standard Input. If more than one file is specified, the filename will appear before each new set of lines listed. Head and tail are standard utilities, usually written in C, available on all UNIX computers. My Amiga versions, head.rexx, and tail.rexx included in this archive are written in AREXX. Head.rexx is functionally identical to the version I use at work on Silicon Graphics workstations. The UNIX version of tail allows only one file to be specified, but my Amiga version allows multiple files, just as head does. Occasionally you want to view both the beginning and end of a file. For this I have written the program ends.rexx, which has no direct UNIX equivalent. The syntax for ends is the same as for head or tail. It will show the first and last lines of each file, separated by a line of ... On a UNIX computer the shell expands wildcards in the filenames on the command line prior to passing it to a program. Hence the head program would receive one command parameter for each file that it has to read. However, on the Amiga, neither the standard AmigaShell, nor the WShell (which I use), perform wildcard expansion. Therefore each program must do its own filename expansion. To do this, I use the FileList() function in the rexxarplib.library, which must be located in the LIBS: directory. I have included two smaller and faster versions of head, which only perform the default operation, and hence do not accept command line options. Defhead.rexx (Defaulthead) is a 2 line, 158 byte program in AREXX. In contrast, the full version of head.rexx, which can handle any number of filename patterns on the command line, each of which can expand into many names, is relatively large, i.e., 1290 bytes, and 59 lines. Fhead.f is the one line source code for Fhead (Falsehead), which is written in "False." The compiled executable is only 312 bytes. False is a wonderful "toy" language written by Wouter van Oortmerssen, and available on Fish Disk 885. It is perfect for this type of application, at least if you like compact obscure code. All of the program files in this archive are released into the public domain, however I request that if you redistribute them, please keep them together with this doc file. If you wish to contact me, I can be reached via the Boston Computer Society, Amiga Bulletin Board (617) 729-7340, or by E-mail at hwollman@mitre.org