Re: undeterministic output when running egrep repeatedly with the same input
On 20/01/2014 23:12, Robert Millan wrote:
> $ for i in $(seq 100) ; do egrep '^#[[:space:]]*define[[:space:]]+MNT_[A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*' /usr/src/kfreebsd-headers-10.0-1/sys/sys/mount.h | grep MNT_RDONLY | head -n 1 ; done | wc -l
> 72
Interestingly, when the receiving end of the pipe egrep writes to is not spawned
in each iteration, the chance of failure is much lower (but still non-zero):
$ for i in $(seq 100) ; do for i in $(seq 100) ; do egrep '^#[[:space:]]*define[[:space:]]+MNT_[A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*' /usr/src/kfreebsd-headers-10.0-1/sys/sys/mount.h ; done | grep MNT_RDONLY | wc -l ; done
100
100
100
100
100
100
100
99
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
99
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
--
Robert Millan
Reply to: