The pipe operator runs both processes concurrently. If the second process needs to read input, it will wait for the first process to write something to the pipe.
But echo
doesn't read input, so it doesn't wait.
If you instead wrote
sleep 5 | { read _; echo "Hello World"; }
the output would be delayed because read
waits for something to be available in the pipe (in this case it will just read EOF because sleep
doesn't write anything to stdout).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…