Display available ram memory in Terminal (no top) and WiFi info

I am searching for something similar to "free" in Linux, to display the amount of free and used memory, and then incapsulate it into a shell script, so "top" isn't good.
I already found the total memory output with "system_profiler SPHardwareDataType | grep Memory | awk '{print $2}" but I can't find any way to display the unused+free memory.

Furthermore I need the output of the total received and sent bytes trough a wlan device.
In Linux, for example, I used "/sbin/ifconfig eth0 | grep 'RX byte' | awk '{print $3 $4}'" but here ifconfig foo doesn't display any info about amount of data received/sent by a device.

Ibook 12'' 1.33ghz and MBP 15'' 2.2ghz, Mac OS X (10.4.11), The MBP that often skipped random letter swhen typing :(

Posted on Jul 15, 2008 6:55 AM

Reply
5 replies

Jul 15, 2008 9:43 AM in response to flapane

I am searching for something similar to "free" in Linux, to display the amount of free and used memory, and then incapsulate it into a shell script, so "top" isn't good.


What's wrong with 'top'?

top -l 1 | grep PhysMem


Furthermore I need the output of the total received and sent bytes trough a wlan device.


You should be able to parse the results from:

netstat -i

Jul 15, 2008 11:04 AM in response to Camelot

Thank you! I didn't know I could parse an output from top because I didn't know the -l argument.
I did this and it worked, maybe it can helps someone:

inact=`top -l 1 | grep PhysMem | awk '{print $6}' | sed -e 's/M.*//'`
free=`top -l 1 | grep PhysMem | awk '{print $10}' | sed -e 's/M.*//'`
i=`echo "$inact+$free" | bc`

For netstat, I can see i/o packets, how to... translate them into Bytes?
thanks

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Display available ram memory in Terminal (no top) and WiFi info

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.