I need to get some specific results from 'free -m' into a variable.
I need those values marked bold - which is total memory / free memory.Output 'free -m' wrote: total used free shared buffers
Mem: 3987 1490 2497 0 3
-/+ buffers: 1486 2501
Swap: 9039 99 8940
Is there a simple and/or easy way to achieve?
Thanks
Edit:
After a some time of try and fail I could achieve it that way:
Since there's two more lines including ':', is this secure?FREERESULT="`free -m`"
TOTAL=$(echo $FREERESULT|cut -d':' -f2|cut -d' ' -f2)
FREE=$(echo $FREERESULT|cut -d':' -f2|cut -d' ' -f4)
Is there something smarter, a one liner probably?