Last active
May 10, 2019 15:51
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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