home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!ukma!netsys!pagesat!spssig.spss.com!news.oc.com!convex!tchrist
- From: Tom Christiansen <tchrist@convex.COM>
- Subject: Re: Where's head?!
- Originator: tchrist@pixel.convex.com
- Sender: usenet@news.eng.convex.com (news access account)
- Message-ID: <1992Nov5.195726.9641@news.eng.convex.com>
- Date: Thu, 5 Nov 1992 19:57:26 GMT
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- References: <291@procor.UUCP>
- Nntp-Posting-Host: pixel.convex.com
- Organization: Convex Computer Corporation, Colorado Springs, CO
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
- Lines: 43
-
- From the keyboard of jamesm@procor.dialogic.com (Mark James):
- :I suppose I've just been spoiled by Berkenix, but when I recently
- :began using Interactive's System V Release 3.2 product, I was
- :shocked to discover that the program 'head' does not exist, nor
- :does it appear anywhere in the documentation. It's not even in
- :/usr/ucb, although there is a 'tail'.
-
- As others have sed, you can just use that.
-
- The following head clone runs pretty quickly and
- even works for "hard" files, like /vmunix.
-
- --tom
-
- #!/usr/bin/perl
- #
- # head -- perl clone of head command, but without heads silly
- # limits regarding line lengths or binary data. Also
- # runs faster and allows pipes ("df|") as args.
- # tchrist@convex.com
-
- $num = ($ARGV[0] =~ /^-(.+)/ && shift) ? $1 : 10;
- die "$0: badly formed number: $1\n" unless $num =~ /^\d+$/;
-
- unshift(@ARGV, '-') unless $argc = @ARGV;
- while (<>) {
- if ($. == 1 && $argc > 1) {
- print "\n" if $deja_imprime++;
- print "=> $ARGV <=\n" ;
- }
- if ($. <= $num) {
- print;
- } else {
- close ARGV;
- }
- }
-
- --tom
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
- "...this does not mean that some of us should not want, in a rather
- dispassionate sort of way, to put a bullet through csh's head."
- Larry Wall in <1992Aug6.221512.5963@netlabs.com>
-