AminetAminet
Search:
84510 packages online
About
Recent
Browse
Search
Upload
Setup
Services

util/cli/headtail.lha

Mirror:Random
Showing:m68k-amigaosppc-amigaosppc-morphosi386-arosi386-amithlonppc-warpupppc-powerupgeneric
No screenshot available
Short:unix-style head/tail, better than others
Architecture:m68k-amigaos
Date:1992-09-01
Download:http://aminet.net/util/cli/headtail.lha - View contents
Readme:http://aminet.net/util/cli/headtail.readme
Downloads:563

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 <file>

would report:
Line2

Line4
End

while

> tail -3l <file>

would report:

Line4
End

You see?

Character units (specifiec with "c" in place of "l") work similarly;

> tail -7 <file>

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.


Contents of util/cli/headtail.lha
 PERMSSN    UID  GID    PACKED    SIZE  RATIO     CRC       STAMP          NAME
---------- ----------- ------- ------- ------ ---------- ------------ -------------
[generic]                 5640    9356  60.3% -lh5- dc3f Aug 31  1992 head
[generic]                 2304    5225  44.1% -lh5- 4e94 Aug 31  1992 headtail.c
[generic]                  640    1144  55.9% -lh5- 3e07 Aug 31  1992 Makefile
[generic]                 5640    9356  60.3% -lh5- dc3f Aug 31  1992 tail
[generic]                  696    1927  36.1% -lh5- 970f Aug 31  1992 tail.man
[generic]                  303     785  38.6% -lh5- cb79 Aug 31  1992 test.sh
---------- ----------- ------- ------- ------ ---------- ------------ -------------
 Total         6 files   15223   27793  54.8%            Sep  1  1992

Aminet © 1992-2024 Urban Müller and the Aminet team. Aminet contact address: <aminetaminet net>