1

From the following link change format for time command, I would like to get exactly the same format of MacOS Catalina time command present in bash into zsh of Debian 10 Buster.

So, I tested the solution given on this link :

$ export TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S'

and if do a : $ time sleep 63

I get :

real    63.00s
user    0.00s
sys     0.00s

whereas into bash of MacOS Catalina, I have with the same command :

real    1m3.030s
user    0m0.004s
sys     0m0.014s 

I mean, on Debian, elapsed time doesn't display the minutes it is over 60 seconds. It always displays only the seconds. Moreover, if lower than 60s, we keep the Om0.004s, i.e Om in front of seconds

How to fix this to have the same format on Debian 10 zsh than MacOS bash ?

1 Answers1

1

I quote from the section TIMEFMT of man zshparam:

A star may be inserted between the percent sign and flags printing time (e.g., %*E); this causes the time to be printed in hh:mm:ss.ttt format (hours and minutes are only printed if they are not zero). Alternatively, m or u may be used (e.g., %mE) to produce time output in milliseconds or microseconds, respectively.

So, while it's not exactly the same format as in bash, with

export TIMEFMT=$'\nreal\t%*E\nuser\t%*U\nsys\t%*S'

you'll get at least the minutes and hours separated:

$ time sleep 63

real    1:03.00
user    0.000
sys     0.003
mpy
  • 28,816