如何通过命令行获得在Linux中的CPU /核心的数量? [英] How to obtain the number of CPUs/cores in Linux from the command line?
本文介绍了如何通过命令行获得在Linux中的CPU /核心的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的剧本,但我不知道如何获得的最后一个元素在打印输出:
执行cat / proc内/ cpuinfo | awk的'/ ^处理器/ {打印$ 3}
的最后一个元素应CPU的1的数量,减
解决方案
执行cat / proc内/ cpuinfo | awk的'/ ^处理器/ {打印$ 3}'|尾-1
或只是
的grep -c ^处理器的/ proc内/ cpuinfo
这将计数的/ proc内/ cpuinfo
I have this script, but I do not know how to get the last element in the printout:
cat /proc/cpuinfo | awk '/^processor/{print $3}'
The last element should be the number of CPUs, minus 1.
解决方案
cat /proc/cpuinfo | awk '/^processor/{print $3}' | tail -1
or simply
grep -c ^processor /proc/cpuinfo
which will count number of lines starting with "processor" in /proc/cpuinfo
这篇关于如何通过命令行获得在Linux中的CPU /核心的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文