[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The difference between `X=x f | cat` and `{ X=x; f; } | cat`
From: |
Greg Wooledge |
Subject: |
Re: The difference between `X=x f | cat` and `{ X=x; f; } | cat` |
Date: |
Thu, 19 Jan 2023 10:53:42 -0500 |
On Thu, Jan 19, 2023 at 03:49:06PM +0000, Kerin Millar wrote:
> time for ((i=0; i < 1000; i++)); do X=x f | cat >/dev/null; done
> time for ((i=0; i < 1000; i++)); do { X=x; f; } | cat >/dev/null; done
>
> Obviously, you may need to tune the number of iterations in order to incur an
> acceptably substantive wall time.
I'd also move the >/dev/null outside the loop. You're adding 1000x
the number of times it takes to make that system call to the execution
times, which might distort things a tiny bit.
Timing aside, "one of them makes X an environment variable and the
other doesn't" was already a sufficient answer to "are these the same".
Everything after that has been silliness.
- The difference between `X=x f | cat` and `{ X=x; f; } | cat`, Peng Yu, 2023/01/19
- Re: The difference between `X=x f | cat` and `{ X=x; f; } | cat`, Peng Yu, 2023/01/20
- Re: The difference between `X=x f | cat` and `{ X=x; f; } | cat`, Peng Yu, 2023/01/20
- Re: The difference between `X=x f | cat` and `{ X=x; f; } | cat`, Kerin Millar, 2023/01/20
- Re: The difference between `X=x f | cat` and `{ X=x; f; } | cat`, Peng Yu, 2023/01/20
Re: The difference between `X=x f | cat` and `{ X=x; f; } | cat`, Emanuele Torre, 2023/01/19