I wanted to simulate execution time of certain scripts for which I found sleep NUMBER does exactly what I want.
In my scenario I needed something like
sleep 5 | command | sleep 5 ...
But it behaved strangely so I've tested sleeps alone, and I was surprised that
This takes 10 seconds sleep 10 | sleep 5
and this also takes 10 seconds sleep 5 | sleep 10
I even tried sleep 1 | sleep in case sleep was listening to standard input stdin
Only thing I got working is when I was looking on how to force stdout as argument (with xargs)
sleep 3; echo 3 | xargs sleep; echo "finished"
But since I need to time the whole execution I had to do
time -p (sleep 3; echo 3) | (xargs sleep; echo "finished")
Hoe to pipe sleeps? If there is a better way, I'd still ike to know why sleep 1 | sleep 1 isn't working in the first place?
(sleep 3; echo 3 | (xargs sleep; echo finished)- what is thesleep 3doing in the left side, and whyecho | xargs? If you want to delay the secondecho,| (sleep 3; echo finished)is enough. – muru Feb 02 '21 at 19:28sleep 3; sleep 3in itself works thanks, buttime sleep 3; sleep 3prints time only of the first command, so I guess solution to that according to those answers would betime (sleep 3; sleep 3)? – jave.web Feb 02 '21 at 19:41cmd1 | cmd2 | ... | cmdn, and you're fakingcmd5, then onlycmd5needs to be(sleep; echo). Why do the rest needsleep? And if there are multiple faked commands, and they are adjacent, only the last needs asleep. – muru Feb 02 '21 at 19:51