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

util/cli/HeadTail11.lha

Mirror:Random
Showing:m68k-amigaosppc-amigaosppc-morphosi386-arosi386-amithlonppc-warpupppc-powerupgeneric
No screenshot available
Short:Show first/last n lines/chars of a file.
Author:D. Chapman/Dan Cannon <dan at blender.demon.co.uk>
Uploader:Dan Cannon <dan blender demon co uk>
Type:util/cli
Architecture:m68k-amigaos
Date:1995-07-17
Download:http://aminet.net/util/cli/HeadTail11.lha - View contents
Readme:http://aminet.net/util/cli/HeadTail11.readme
Downloads:569

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 <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/HeadTail11.lha
 PERMSSN    UID  GID    PACKED    SIZE  RATIO     CRC       STAMP          NAME
---------- ----------- ------- ------- ------ ---------- ------------ -------------
[generic]                  259     628  41.2% -lh5- 2cac Jul 16  1995 HeadTail11.info
[generic]                  264     628  42.0% -lh5- 41d0 Jul 16  1995 HeadTail11/C.info
[generic]                 7100   11120  63.8% -lh5- a962 Jul 16  1995 HeadTail11/C/HeadTail
[generic]                 1937    3825  50.6% -lh5- c13f Jul 16  1995 HeadTail11/ReadMe
[generic]                  237     463  51.2% -lh5- c634 Jul 16  1995 HeadTail11/ReadMe.info
[generic]                  269     628  42.8% -lh5- 96c5 Jul 16  1995 HeadTail11/Source.info
[generic]                 2045    4697  43.5% -lh5- 5ee2 Jul 16  1995 HeadTail11/Source/headtail.c
[generic]                  107     172  62.2% -lh5- 742d Jul 16  1995 HeadTail11/Source/Makefile
---------- ----------- ------- ------- ------ ---------- ------------ -------------
 Total         8 files   12218   22161  55.1%            Jul 17  1995

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