🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.editors
Article #3626

Re: Delete lines

#3626
From: Blair P. Houghton
Date: Mon, 15 May 1989 13:40
49 lines
2178 bytes
In article <3801@merlin.usc.edu> kailanhw@aludra.usc.edu () writes:
>Hello, I need some help.
>I have a files which format to be 66 lines per page.
>Now I need to change it to 60 lines per page.
>So I have to delete last 6 lines of each pages.

I'm going to assume you are speaking precisely in that sentence.
I'm going to give you a C program that merely lops off the last six lines,
rather than reformatting from 66-line pages to 60-line pages with one-
inch top and bottom margins.

>Is there a fast way to do it?

If there's a way faster than this, you've a better compiler
than I, Gunga Din:

/*-------------------------Rip Gently---------------------------------*/
    /* 66260.c -- the program that podectomizes your pages.     *
     * Copyright?  You gotta be kidding...it's a four-cent      *
     * program at best.  Let the public domain have this        *
     * one forever.  Written By Blair P. Houghton in 1989.      */

    /* Well, not forever, it's not got function prototypes, so  *
     * it isn't ANSI...						*/

    #include <stdio.h>
    extern char *gets();
    extern int puts();

    /* No arguments.  It reads stdin and writes stdout. */
    main()
    {
            int lineno=0;
            char line[80];

	    /* One statement.  No sweat.  The sed	*
	     * script is a novella in comparison.	*/
            while( gets(line) != NULL )
                    if ( ++lineno < 61 )
                            puts(line);
                    else if ( lineno == 66 )
                            lineno = 0;
    }
/*--------------------------End of Program------------------------*/

/*				--Blair
 *				  "It took longer to get it
 *				   included in this posting..."
 */
Technical Details
Message-ID: <2870@buengc.BU.EDU>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!buengc!bph
References: <3801@merlin.usc.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!buengc!bph
From: bph@buengc.BU.EDU (Blair P. Houghton)
Newsgroups: comp.editors
Subject: Re: Delete lines
Message-ID: <2870@buengc.BU.EDU>
Date: 15 May 89 13:40:25 GMT
References: <3801@merlin.usc.edu>
Reply-To: bph@buengc.bu.edu (Blair P. Houghton)
Followup-To: comp.editors
Distribution: usa
Organization: Boston Univ. Col. of Eng.
Lines: 49