Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在命令中显示我的 CPU 使用率,取百分比并分配给变量。
此外,它可能是计算的形式。也许是一种占据顶部的方式。
vmstat | awk 'NR==3 {print $(NF-2)" "$(NF-1)" "$(NF)}'
您将拥有三个值:用户、系统和空闲百分比。如果您不需要它们中的任何一个,您可以修改awk-script。
awk