Skip to content

Instantly share code, notes, and snippets.

@o0-o
Last active May 7, 2019 01:13
Show Gist options
  • Save o0-o/13fdd4ece3d34bd41d35ae22ee233eba to your computer and use it in GitHub Desktop.
Save o0-o/13fdd4ece3d34bd41d35ae22ee233eba to your computer and use it in GitHub Desktop.
[CPU Model] Print the make of the CPU #Shell
# cpu_model.sh
( # linux (proc)
grep "model name" /proc/cpuinfo |
uniq |
sed 's/[[:space:]]\{1,\}/ /g' |
sed 's/^model name : //' ||
# linux (lscpu)
lscpu |
grep "Model name:" |
sed 's/[[:space:]]\{1,\}/ /g' |
sed 's/^Model name: //' ||
# macos
sysctl -n machdep.cpu.brand_string ||
# bsd
sysctl -n hw.model |
sed 's/[[:space:]]\{1,\}/ /g' ||
# linux/bsd (dmidecode)
dmidecode --type processor |
grep "Version: " |
uniq |
sed 's/[[:space:]]\{1,\}/ /g' |
sed 's/^ Version: //'
) 2>/dev/null ||
exit 1 #failure
exit 0 #success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment