[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why tail coreutil cannot work as its input is from tee
From: |
Andreas Kusalananda Kähäri |
Subject: |
Re: Why tail coreutil cannot work as its input is from tee |
Date: |
Mon, 6 Sep 2021 11:19:08 +0200 |
On Mon, Sep 06, 2021 at 07:38:03AM +0000, Budi wrote:
> How come tail coreutil cannot work as its input is from tee
>
> $ echo -e '9\n4\n3\n2\n8\n7\n3\n1' |tail -1
> 1
>
> But :
>
> $ echo -e '9\n4\n3\n2\n8\n7\n3\n1' |tee >(head -1) |tail -1
> 9
>
> Please help explain
I don't see how this is a bug report against the bash shell.
Note that the output from your pipeline is non-deterministic:
$ echo -e '9\n4\n3\n2\n8\n7\n3\n1' |tee >(head -1) | tail -1
1
$ echo -e '9\n4\n3\n2\n8\n7\n3\n1' |tee >(head -1) | tail -1
9
This is on an OpenBSD system. This depends on whether tee has a chance
of outputting the complete data from echo to its standard output first,
before the head outputs its data. With GNU tools, I can't get the
pipeline to output 1, but I know there's a chance it may eventually
output 1 rather than 9.
--
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden
.