[NTLUG:Discuss] OT: head and tail

Terry trryhend at gmail.com
Tue Apr 5 11:36:30 CDT 2005


On Mar 30, 2005 1:35 PM, Fred James <fredjame at fredjame.cnc.net> 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.
> 
>  From man tail (on IRIX):
> " Tails relative to the end of the file are stored in a buffer, and thus
>      are limited in length.  Various kinds of anomalous behavior may happen
>      with character special files.  The tail command will only tail the last
>      256 Kbytes of a file regardless of its line count.
>  "
>  From man tail (on SVR4 Release 4.0)
> "          Tails relative to the end of the file are stored in a
>           buffer, and thus are limited in length.  Various kinds of
>           anomalous behavior may happen with character special files.
> 
>           The tail command will only tail the last 4096 bytes of a
>           file regardless of its line count.
>  "
> 
> Similar reading on Sun
> 
> ... no such item in man on Linux.  But then, Linux doesn't have the
> option for 'tail +n', which is the solution on the others.
> 

Don't know if this is relevant but, tail may not have +n but has -n
 -n, --lines=N   output the last N lines, instead of the last 10

> I didn't know that.
> Regards
> Fred James
> 
> --
> Compassion alone stands apart from the continuous traffic between good and evil proceeding within us.  "Om Mani Padme Hum"
> 
> _______________________________________________
> https://ntlug.org/mailman/listinfo/discuss
>




More information about the Discuss mailing list