Changes

Jump to navigation Jump to search
136 bytes added ,  11:59, 30 September 2015
reference link
== Free Memory ==
Use <code>echo</code> to output the result of a sub-shell, and a few extra characters (' - + p'), which is then piped to the (reverse-polish) desk calculator. Con<code>cat</code>enate the /proc/meminfo file, printing it on STDOUT. Using extended-regex <code>grep</code>, we search for lines of output that begin with "MemFree", "Cached" or "Writeback" followed by the colon character. Piping to <code>awk</code>, we can print out the string in position 2 of each line. Those values are ultimately processed in the calculator by popping the last two numbers off the stack (Writeback and Cached), and adding that result to the first number (MemFree).<ref>[http://www.computerweekly.com/feature/Write-through-write-around-write-back-Cache-explained Cache explained]</ref>
<source lang="bash">
echo $(cat /proc/meminfo | egrep '^(MemFree|Cached|Writeback):' | awk '{print $2}') - + p | dc
VmSize: 158212 kB
</pre>
 
{{References}}
[[Category:Bash]]
[[Category:System Administration]]
4,558

edits

Navigation menu