How to read total RAM in GBs?

I am aware of the commands to find the total RAM on Linux and Unix for example vmstat .

Can you please tell me which tool / command can give me the Total RAM reading in GBs [gigabytes] on Solaris Unix and Linux ?

There is a tool on Linux called numfmt :

$ wc -c < myfile | numfmt --to=iec
34M

Unfortunately it is not on Solaris to my knowledge. It is, however, part of the Gnu coreutils, so it may be possible to compile it from source.

Andrew

For good precision use awk.
Most handy is a shell function

kb_to_iec(){
awk '{
 if ($1<1024) {scale=1; unit="K"} else
 if ($1<1048576) {scale=1024; unit="M"} else
 if ($1<1073741824) {scale=1048576; unit="G"} else
 if ($1<1099511627776) {scale=1073741824; unit="T"} else
  {scale=1099511627776; unit="P"}
 printf "%.1f%s\n",$1/scale,unit
}'
}
echo 1023 | kb_to_iec
1023.0K
echo 1024 | kb_to_iec
1.0M