View Single Post
Posts: 36 | Thanked: 42 times | Joined on Jan 2010
#135
Originally Posted by Palleman View Post
Or some awk:
Code:
cat /proc/uptime | awk '{printf "%d days, %.2d:%.2d\n",int($1/86400),int($1%86400/3600),int($1%3600/60)}'
/P
Don't want to do my BOFH but you call two commands and one is enough if you rewrite like this :

Code:
awk '{printf "%d days, %.2d:%.2d\n",int($1/86400),int($1%86400/3600),int($1%3600/60)}' /proc/uptime
Code:
awk '{if (int($1/86400)>0){printf "%d days, ",int($1/86400)};printf "%.2d:%.2d\n",int($1%86400/3600),int($1%3600/60)}' /proc/uptime
Ok, I'm not sure the cat will empty the battery but ...

Last edited by nbc; 2010-02-24 at 21:11.