Skip to content

Instantly share code, notes, and snippets.

@o0-o
Last active May 10, 2019 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save o0-o/2a4dfea176c6c21c7b88d5c9f55392be to your computer and use it in GitHub Desktop.
Save o0-o/2a4dfea176c6c21c7b88d5c9f55392be to your computer and use it in GitHub Desktop.
[Memory Modules] Prints detailed information about memory modules installed on the host #Shell
# mem_modules.sh
# slot size type ecc make model serial
# linux/bsd x86
dmidecode --type memory |
grep --extended-regexp --regexp='^[[:space:]]*Size:|^[[:space:]]*Locator:|^[[:space:]]*Type:|^[[:space:]]*Type Detail:|^[[:space:]]*Manufacturer:|^[[:space:]]*Serial Number:|^[[:space:]]*Part Number:' |
sed 's/^[[:space:]]*Size: /@\&/g' | #add @& placeholder for beginning of each valid entry
sed 's/^.*: //g' | #remove labels
sed 's/[[:space:]]*$//g' | #remove trailing whitespace
tr '\n' '\t' | #tab delimit
tr '@' '\n' | #new line for each valid entry
grep --invert-match "No Module Installed" | #don't display empty slots
grep '&' | #only display valid entries
tr -d '&' | #remove placeholder
awk -F $'\t' '{ print $2,'\t',$1,'\t',$3,'\t',$4,'\t',$5,'\t',$7,'\t',$6 }' || #reorder output
exit 1 #failure
exit 0 #success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment