When I issue a command on the terminal uptime
, it returns:
13:21:52 up 13:02, 3 users, load average: 1.10, 1.09, 0.96
Then, I want to print the load averages which are at field 8,9,10 by using:
uptime | awk '{print $8}' | tr -d ","
Then the result will be: 1.10
But, sometimes, when the pc is up for more than a day, it returns:
13:22:12 up 6 days, 19:50, 3 users, load average: 1.10, 1.09, 0.96
As you can see, the number of field columns is not fixed. I don't want to manually edit the field number I want to print. So, I thought of reading the line starting from the right side. With that, 0.96 will be the field 0, 1.09 will be field 1, and so on. I don't care about the values near the left side.