tag 17423 notabug
close 17423
stop

On 05/06/2014 11:15 AM, Pawel Jagla wrote:
> 
> Hello
> 
> I discovered a bug with 'tee' command when I sort items in file, and try to
> overwrite output to the same file, like that :
> sort filename |tee filename
> 
> Sometimes it sorts and overwrites file with sorted items, and sometimes it
> clears the file completely (so the file is empty).
> Of course I know that I can do that by adding operator '-o' to sort.
> BTW I am working under RedHat 6 Enterprise, and bash shell.

tee doesn't buffer everything and then write filename,
it does so in parallel, thus giving rise to the "random"
behavior depending on when the sort and tee processes are scheduled.

sort -o is a good way to achieve the required buffer,
since sort needs to buffer all input anyway before
outputting anything.

thanks,
Pádraig.



Reply via email to