#!/bin/sh ######################################## # Description: This script is used to show CPU information. # Required files: id, echo, sysctl, sed, system_profiler, grep, awk ######################################## #################### # Main #################### cpu_model=`sysctl -n machdep.cpu.brand_string | sed 's/^ *//;s/ *$//' | sed 's/*/\ /g'` physical_cpus=`system_profiler SPHardwareDataType | grep 'Number of Processors:' | awk '{print $4}'` cores_per_cpu=`sysctl -n machdep.cpu.core_count` threads_per_cpu=`sysctl -n machdep.cpu.thread_count` if [ "$threads_per_cpu" -gt "$cores_per_cpu" ] then hyper_threading="Yes" else hyper_threading="No" fi logical_cpus=`sysctl -n hw.ncpu` echo Model: $cpu_model echo Hyper-Threading: $hyper_threading echo Physical CPU\'s: $physical_cpus echo Cores per CPU: $cores_per_cpu echo Threads per CPU: $threads_per_cpu echo Logical CPU\'s: $logical_cpus exit 0