This question already has an answer here:
Considering this Q&A about the order of execution in the shell as it relates to redirection, and despite the fact that if a file doesn't exist it gets created first so that
cat example.txt | shuf > example.txt doesn't complain that the file doesn't exist - which just confirms the order from what I understand - then why is it that about once every thousand times on my system the shuffle works when I do this (backup contains 15 static values each on their line)
for i in $(seq 1 1000); do cp backup test echo $i cat test | shuf > test cat test done
How can there seemingly be an exception to the rule?