In order to get total amount of the system memory as GigaByte in a bash script:
#!/bin/bash
mem_line=`cat /proc/meminfo |grep MemTotal`
mem_kb=`echo $mem_line | tr -cd '[[:digit:]]'`
mem_gb=$(awk "BEGIN{print $mem_kb/1024/1024}")
echo "System Memory (KB): "$mem_kb
echo "System Memory (GB): "$mem_gb
Comments
Post a Comment