Bash 别名 cpu 用法

Bash alias cpu usage

我试过这个命令,但我有一个百分比错误计算器:

alias cpu="mpstat | awk '$12 ~ /[0-9.]+/ { print 100 - \"%\" }'"

感谢您的帮助

改成这样:

alias cpu="mpstat | awk '$12 ~ /[0-9.]+/ { print 100 - $12\"%\" }'"

\100 - 之后丢失了。

-> mpstat
Linux 3.2.0-69-virtual (myhost)     01/06/2017  _x86_64_    (8 CPU)

10:18:16 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
10:18:16 PM  all   12.06    7.00    7.96    0.02    0.00    0.24    0.22    0.00   72.49

-> cpu
27.51%