06-03-2020, 02:29 AM
Code: (Select All)
(.............)
# Reading total memory in MB
tram=$( free -m | awk 'NR==2 {print $2}' )
# Reading Swap in MB
vram=$( free -m | awk 'NR==3 {print $2}' )
(.............)
echo "Memory : $tram MB" | tee -a $HOME/bench.log
echo "Swap : $vram MB" | tee -a $HOME/bench.log
'free -m' gives its output in mebibytes (symbol: MiB) and not in megabytes (symbol: MB.)
Code: (Select All)
# The unit MB is defined by the International System of Units (SI).
1 Megabyte (MB) = (1000)^2 bytes = 1000000 bytes.
# The unit MiB is defined by the International Electrotechnical Commission (IEC)
1 Mebibyte (MiB) = (1024)^2 bytes = 1048576 bytes.