bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Head too greedy


From: John Summerfield
Subject: Head too greedy
Date: Mon, 01 Jan 2007 20:58:39 +0800

I've been doing this for years, thinking it prints the first few and
last few lines of something:
address@hidden ~]$ yes stuff | head -3000 | cat -n | (head -2;tail -2)
     1  stuff
     2  stuff
  2999  stuff
  3000  stuff
address@hidden ~]$ 

In this example, the results are what I desire. However,
address@hidden ~]$ yes stuff | head -300 | cat -n | (head -2;tail -2)
     1  stuff
     2  stuff
address@hidden ~]$ 

I presume this arises because head's reading ahead (if not head, then
glibc on head's behalf), and when head's printed enough lines it simply
closes its files (or maybe just exit()s.

I don't see when this behaviour might actually be desired. I'd like to
see its behaviour changed so that head consumes no more lines than it
will report. (I note the man page is silent on what should happen, no
surprise there).

If you think that the current unpredictable behaviour is sometimes
desirable, then could we please have something, maybe --nobuffer, to
turn it off?

Thank you so much.
 
-- 
John Summerfield <address@hidden>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]