Last active
October 26, 2022 02:53
-
-
Save ferbass/ec4d103240e720eb24f8d65454886726 to your computer and use it in GitHub Desktop.
Convert /proc/meminfo to KB, MB and GB as appropriate
This file contains 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
# convert any kB lines to MB: | |
awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | |
# converts to gigabytes: | |
awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | |
# convert to MB or GB as appropriate: | |
awk '$3=="kB"{if ($2>1024^2){$2=$2/1024^2;$3="GB";} else if ($2>1024){$2=$2/1024;$3="MB";}} 1' /proc/meminfo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment