LINUX TP1 need help in programming.
HELLO, I will try to translate this from french into english. So I was given homework, and I am a bit of a nutjob when it comes to programming in linux and would need explanations because I just do not know where to start from.
Display the contents of the file " /proc/meminfo " , it gives the state of the occupation memory: MemTotal: 807088 kB MemFree: 13456 kB Buffers: 95436 kB Cached: 470396 kB SwapCached: 0 kB Active: 377776 kB Inactive: 339676 kB HighTotal: 0 kB HighFree: 0 kB LowTotal: 807088 kB What we are interested in the first 2 lines (total memory and memory remaining), the size is expressed in kb ( Kilo-bytes) of after these information, it wants to know the rate of occupation memory. I need the thing down here in a box... Mémoire totale : 788,17 Mo Mémoire occuppée : 775,05 Mo Mémoire libre : 13,12 Mo "cat" , "head", "Cut" , "TR" and a script "awk" and for verification So how exactly to I put it into a script while using awk to build tables and calculate the stuff. Taux occupation mémoire : 98,34% => Alarm |
This should get you started:
Code:
awk '/MemTotal/ {print "Mémoire totale : " int($2/1024) " Mo"}' /proc/meminfo |
Great, so for the rest I would use if and echo? to show the values, emmm how do I get the mem and free on same line withouth the [root] showing in front?
|
All times are GMT -5. The time now is 08:57 PM. |