diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 12:41:09 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 12:41:09 +0300 |
commit | 8c042f99cc7465c86351d21331a129111b75345d (patch) | |
tree | 9656e653be0e42e5469cec77635c20356de152c2 /test/lastnpages | |
parent | 8ceb5f934787eb7be5fb452fb39179df66119954 (diff) | |
download | egawk-8c042f99cc7465c86351d21331a129111b75345d.tar.gz egawk-8c042f99cc7465c86351d21331a129111b75345d.tar.bz2 egawk-8c042f99cc7465c86351d21331a129111b75345d.zip |
Move to gawk-3.0.0.
Diffstat (limited to 'test/lastnpages')
-rw-r--r-- | test/lastnpages | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/test/lastnpages b/test/lastnpages deleted file mode 100644 index 0acb7738..00000000 --- a/test/lastnpages +++ /dev/null @@ -1,47 +0,0 @@ -From nstn.ns.ca!news.cs.indiana.edu!news.nd.edu!spool.mu.edu!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!fluke!ssc-vax!brennan Mon May 6 23:41:40 ADT 1991 -Article: 26492 of comp.unix.questions -Path: cs.dal.ca!nstn.ns.ca!news.cs.indiana.edu!news.nd.edu!spool.mu.edu!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!fluke!ssc-vax!brennan -From: brennan@ssc-vax.UUCP (Michael D Brennan) -Newsgroups: comp.unix.questions -Subject: Re: How to print last <n> pages of a file -Message-ID: <3948@ssc-bee.ssc-vax.UUCP> -Date: 6 May 91 15:42:00 GMT -Article-I.D.: ssc-bee.3948 -Organization: Boeing Aerospace & Electronics, Seattle WA -Lines: 33 - - -The following shell & (new) awk program prints the last n pages. - -If you get more than 65 lines to a page, the program that inserts -the ^L's should be fixed. - -------------------------------------------------------------- -#!/bin/sh -# usage: lastpages -- prints 1 page reads stdin -# lastpages n -- prints n pages reads stdin -# lastpages n files -- prints n pages, reads file list - -program='BEGIN{RS = ORS = "\f" } - - -{ page[NR] = $0 - if ( NR > numpages ) delete page[NR-numpages] -} - -END { - i = NR - numpages + 1 - if ( i <= 0 ) i = 1 - - while( i <= NR ) print page[i++] -}' - - -case $# in -0) awk "$program" numpages=1 - ;; -1) awk "$program" numpages=$1 - ;; -*) pages=$1 ; shift - awk "$program" numpages=$pages $* ;; -esac - - |