dash and build-in time command: not expected behavior

Stefan Schweter stefan at schweter.it
Wed Jun 18 15:55:03 UTC 2014


Dear ubuntu-users,

I'm currently found out some "strange" behavior with the built-in time 
command in combination with dash:

$ time echo "test" | wc -l | sleep 5

0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 
620maxresident)k

0inputs+0outputs (0major+200minor)pagefaults 0swaps


I expected that the time command measure the time for the whole pipe 
construct - but in this case I guess it finishes after the echo command.


Same command in a bash returns:

time echo "test" | wc -l | sleep 5

real 0m5.003s

user 0m0.001s

sys 0m0.002s


How can I achieve the time command in dash to measure the time for the 
whole pipe process?

Thanks many in advance,

Stefan




More information about the ubuntu-users mailing list