grep从正常运行时间中取出平均负载 [英] grep out load average from uptime
本文介绍了grep从正常运行时间中取出平均负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想做的就是让命令正常运行,并获得平均负载
what I want to do is take the command uptime, and get the load averages
$ uptime
07:01:30 up 20:29, 2 users, load average: 0.32, 0.39, 0.54
我感觉这可以用awk完成,但是我不太确定如何做. 请协助.
I have a feeling this is something I can do with awk, but I am not quite sure how. pls assist.
推荐答案
您可以使用带有后向引用的正则表达式:即找到任何字符序列(.*),但只能在平均值之后的点:
You can use a regex with backreferences: i.e. find any sequence of characters (.*) but only at a point directly after average:
uptime | grep -oP '(?<=average:).*'
这篇关于grep从正常运行时间中取出平均负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文