简体   繁体   中英

Linux/Raspberry Pi command to help round to 2 decimal

I am running the following command to get Free Memory, and want to change it from KB to MB to the second decimal.

grep MemFree /proc/meminfo | awk {'print $2*.001'}

Output: 96.163 | Want it to be Output 96.16

How do I round? I have seen where it says to use scale=2, but then it just prints out scale=2, I have tried puttting it before anfer and inbetween several different ways with no luck. how can I do this.

I am editing the .bashrc file to I can see the output in MB no KB

awk '/MemFree/ { printf("%0.2f\n", $2 * .001) }' /proc/meminfo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM