答案1
和awk
:
$ top -bn2 | awk '/^%Cpu/ && n++ {print $2}'
85.7
答案2
替代方法:
┌─[root@Fedora]─[~]─[03:43 pm]
└─[$]› top -bn 2 | grep Cpu | tail -1 | awk '{print $2}'
0.6
和awk
:
$ top -bn2 | awk '/^%Cpu/ && n++ {print $2}'
85.7
替代方法:
┌─[root@Fedora]─[~]─[03:43 pm]
└─[$]› top -bn 2 | grep Cpu | tail -1 | awk '{print $2}'
0.6