/proc/uptime in Mac OS X

后端 未结 4 719
不知归路
不知归路 2021-02-08 19:55

I need the EXACT same output as Linux\'s \"cat /proc/uptime\".

For example, with /proc/uptime, you\'d get

1884371.64 38646169.12

4条回答
  •  余生分开走
    2021-02-08 20:43

    Here is what I Do to get the the values instead of Cut method

    sysctl kern.boottime | awk '{print $5}'
    

    Where $5 is the Range of the string

    Example

    $1 Gives you "sysctl kern.boottime"
    $2 Gives you "{"
    $3 Gives you "sec"
    

    from the String

    kern.boottime: { sec = 1604030189, usec = 263821 } Fri Oct 30 09:26:29 2020
    

提交回复
热议问题