Issue
I want to use awk only to calculate memory usage from /proc/meminfo file.
I tried to do awk ‘NR==1 || NR==2 {print $2}
it prints the 2nd column in the first 2 lines ( MemTotal and MemFree ) but I want to output the difference.
Do you have any ideas?
Solution
This should work:
awk 'NR==1{T=$2} NR==2{F=$2; print(T-F); exit}' /proc/meminfo
Answered By - Mark Setchell Answer Checked By - David Goodson (WPSolving Volunteer)