This question already has an answer here:
I'm using awesome wm with bashets to make a little text widget to display the free memory. I wanted to convert the number from total kB to gigs (i.e. 1.2). this is what I came up with...
mem_Kb=$(grep -i memfree /proc/meminfo | cut -d: -f2 | tr -d [kB] | sed "s/^[ \t]*// ; s/[ \t]*$//") mem_Gig=$(echo "scale = 1 ; $mem_Kb / 1000000" | bc ) echo mem_Gig: $mem_Gig
what are some better / cleaner ways?