I would like to shuffle output of find
BUT with a fixed seed, so that every time I run the command I get the same output.
Here's how I shuffle:
find . -name '*.wav' | shuf
The issue is that every time we have a new seed -> new order. My attempt to fix it:
find . -name '*.wav' | shuf --random-source=<(echo 42)
That works only on occasions (i.e. just a few cases, in a deterministic way). Most of the time it fails with:
shuf: ‘/proc/self/fd/12’: end of file
Same error is produced by e.g.
seq 1 100 | sort -R --random-source=<(echo 42)
That I have seen being used in other places.
This works though:
printf '%s\n' a b c | shuf --random-source=<(echo 42)
Why is that? And how I can fix it? I am open to any suggestions. Output of the find
is a part of a larger script. The solution should work for bash
and zsh
.
Aucun commentaire:
Enregistrer un commentaire