Short: Show first/last n lines/chars/blocks of a file Author: D. Champion, Dan Cannon, Alex Carmona Uploader: AmigaOne TheWorld net (Alex Carmona) Type: util/shell Version: 1.3 Architecture: ppc-amigaos >= 4.0.0 HeadTail is a dual purpose command that acts as Head or Tail depending on its own filename. If the command name ends with tail it will act as Tail, otherwise it will default to Head. It can be used to split or extract portions of binary files too, but in that case the output should be piped or redirected to a file and the [l]ine option should not be used. Quick installation: Either copy HeadTail to C:Head and again as C:Tail or make a link from C:Head to C:Tail if disk space is limited. The newlib version is smaller and works the same way but requires newlib.library version 1.6 or greater in Libs: v1.3 Smaller newlib version included. Requires newlib.library v1.6+ v1.2 This is a quick port to Amiga OS4. While I was at it I also fixed a few bugs and added a help section for the command line. ----- v1.1 Read Me ----- This is an update to headtail.lha, written by D. Chapman. It was going wrong sometimes, I changed it to work with longer lines. While I was at it, I made it so that the file name can be case insensitive (eg. you can call it head, Head, tail, TAIL, etc...) because it checks its own file name to work out whether you want head or tail. Anyway, copy HeadTail to C:Head and C:Tail and you're sorted. Dan. ----- Original Read Me ----- Short: unix-style head/tail, better than others Well, yes, they are, to be honest. I haven't yet seen a "head" or "tail" program for AmigaDOS which even implemented the lbc stuff in the "real" tail for Unix. Though numerous, all the tails I've seen can only do lines, with one exception that could do chars. This last, however, couldn't read from standard input. I found my work severely limited; I maintain that head and tail are among the most useful tools in the unix environment. So here's a tail program that reads any number of files, or standard input; if more than one file is read, the start of each file is noted in stderr, with files sections themselves going to stdout. Unlike most other Amiga tails I've seen, headtail can do head-relative or tail-relative tailing by using "+" or "-" before the count. E.g., for the file: Start Line1 Line2 Line4 End > tail +3l would report: Line2 Line4 End while > tail -3l would report: Line4 End You see? Character units (specifiec with "c" in place of "l") work similarly; > tail -7 on the above example file would return: e4 End (You must remember to count line feeds.) Blocks work the same way; a block is equivalent to 512 characters. You can change this in the source code to 488 if you use an OFS system; it will more accurately reflect your actual file structure. AND, AS AN ADDED BONUS: The Unix "head" is included, too. Soaring above even Unix head, however, headtail's head will take all the same arguments as tail. The only difference in meaning is that "+" and "-" swap places; i.e, Program Sign Meaning tail + count is relative to start of file tail - count is relative to end of file head + count is relative to end of file head - count is relative to start of file Thus Unix-formatted commands work with headtail, but there are more option if you want them. BUT WAIT -- THERE'S EVEN MORE! As a special for Kickstart v36+ users, head and tail are included as one program. It works like compress: there's one program, and its function is determined by its name. Basic installation consists of copying tail to somewhere in your path, and making a link from "head" to "tail". (You could, of course, do it the other way.) If called as "head", the program performs head stuff; if called as "tail", it does tail stuff. If called something else, it still does tail stuff. If you don't have 2.0, you should. But you can still use headtail by just copying the program to "head", then to "tail". They don't have to be links, but it saves disk space if they are. HeadTail was written by David Champion some time in July - August 1992. It was compiled with Matt Dillon's DICE, and the source code is geared toward that compiler. SAS users will have to perform surgery to make it work, I know. I tried and gave up becasue I hate SAS anyway. Aztec users might have to do cosmetic stuff. GCC works fine; just be sure you've either #defined of -D-defined GCC. This stuff, binary and source, is public domain. I release all liability for damages brought about by usage at just the wrong time of day in La Paz, or whatever else could cause a problem, along with rights to the code. It's everyone's now. now.