bug-coreutils
[Top][All Lists]
Advanced

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

bug#11631: Head command does not position file pointer correctly for neg


From: Pádraig Brady
Subject: bug#11631: Head command does not position file pointer correctly for negative line count
Date: Tue, 05 Jun 2012 11:30:59 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 06/05/2012 11:03 AM, Voelker, Bernhard wrote:
> Anoop Sharma wrote:
> 
>> Head command does not position file pointer correctly for negative line
>> count. Here is a demonstration of the problem.
> 
> The problem doesn't seem to be limited to negative
> line counts. I replaced the 10 ABC lines by a number
> sequence to demonstrate this issue clearer.
> 
>   $ seq 10 | ( head -n -2 ; echo xxx ; cat )
>   1
>   2
>   3
>   4
>   5
>   6
>   7
>   8
>   xxx
>   $ seq 10 | ( head -n 2 ; echo xxx ; cat )
>   1
>   2
>   xxx
> 
> So head eats all of the input. The info page is silent
> about this.
> 
> Have a nice day,
> Berny

Well reading from files should be more flexible
than pipes as we can reset positions in files with seek.
This works for -c but not for -n.
I'll look at fixing this issue this evening.

For pipes we need to consume the data to determine
what to throw away, and there is no facility to
replace that. I'll try and document this edge
case in the info too.

cheers,
Pádraig.





reply via email to

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