I am trying to get a rounded amount of average load in the last 5 minutes. So here is my command:
uptime | awk -F, '{print $5}'|printf "%.0f\n"
Seems wrong as it always gives me 0.
If I tried to use the variable as an intermediate between awk and printf, then it is correct.
avgload=$(uptime | awk -F, '{print $5}') printf "%.0f\n" $avgload
So, is there something wrong with my first attempt?
Thank you and welcome!
UPDATE:
Just to get the average load in the last 5 minutes, here is the result of working on my Linux server (Kubuntu)
$ uptime
13:52:19 up 29 days, 18 min, 15 users, load average: 10.02, 10.04, 9.58
On my laptop (Ubuntu) it looks like
`$ uptime
13:53:58 up 3 days, 12:02, 8 users, average: 0.29, 0.48, 0.60 `
That is why I take the 5th field.
source share