[NTLUG:Discuss] OT: head and tail

Kevin Brannen kbrannen at pwhome.com
Wed Apr 6 21:55:05 CDT 2005


Fred James wrote:

> All
> (Off topic (?) : head and tail)
>
> Starting with a 23,083 line text document, and wanting to discard 131 
> line of the top and 5 off the bottom.
>    head -23078 filename | tail -22947 > newfilename
> right?  Wrong.  The resulting file was 473 lines, but ...
>    head -23078 filename | tail +131 > newfilename
> works as expected.

...

You can always use sed for this, e.g.:

sed -ne '132,23078p' filename > newfilename

Of course, I could also use awk, perl, bash, ksh, ... :-)

HTH,
Kevin




More information about the Discuss mailing list