Re: [dev] print utility

From: Sam Watkins <sam_AT_nipl.net>
Date: Wed, 3 Apr 2013 01:45:08 +1100

On Tue, Apr 02, 2013 at 01:29:11PM +0200, markus schnalke wrote:
> [2013-04-02 15:23] Sam Watkins <sam_AT_nipl.net>
> >
> > I suggest to extend your program so it can also print a range of lines
> > (and thus subsume the functions of 'head' and 'tail' while doing more
> > and yet staying fairly focused). You could perhaps use negative numbers
> > to count back from the final line. It should be able to cut off 6 lines
> > from the end of a file, or print from lines 10 through to the 2nd-last line.
>
> Please don't write this tool as it is already available: ed(1):
>
> echo '1,$-6p' | ed - "$1"
> echo '10,$--p' | ed - "$1"
>
> Better learn about software leverage!

Well in many cases ed is not suitable for this job - large files,
streaming input - and this reads better:

  lines 1 -6

I was suggesting how the OP might make his tool more useful and flexible
- rather than just discouraging him "sed does that!".

Anyway this is tedious so I'll stop arguing.
Received on Tue Apr 02 2013 - 16:45:08 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 02 2013 - 16:48:05 CEST