直接上代码 保存下来就可以运行了
#!/bin/bash physical_name=`cat /proc/cpuinfo | grep 'model name' |uniq|awk -F : '{print $NF}'` physical=`cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l` cpu=`cat /proc/cpuinfo |grep "cores"|uniq|awk '{print $NF}'` thread=`grep 'processor' /proc/cpuinfo | sort -u | wc -l` let tmp=thread/physical let per_cpu_thread=tmp/cpu echo "CPU型号为:$physical_name" echo "CPU数量为:$physical" echo "每个CPU包含的逻辑CPU数量为:$cpu" echo "每个逻辑CPU线程数为:$per_cpu_thread" echo "总共线程数量为:$thread"