从正常运行时间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.
推荐答案
您可以使用带有反向引用的正则表达式:即查找任何字符序列 (.*) 但只能在 average 之后的一个点处:
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屋!
查看全文