Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-19-2016, 12:30 PM   #1
LQ Newbie
Registered: Feb 2016
Location: Canada
Distribution: Suse Mint
Posts: 19

Rep: Reputation: Disabled
Cool 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
Old 02-19-2016, 01:47 PM   #2
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 & 7
Posts: 3,269

Rep: Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893
This should get you started:
awk '/MemTotal/ {print "Mémoire totale : " int($2/1024) " Mo"}' /proc/meminfo
Just add additional cases in the awk script for what you need.
1 members found this post helpful.
Old 02-19-2016, 02:12 PM   #3
LQ Newbie
Registered: Feb 2016
Location: Canada
Distribution: Suse Mint
Posts: 19

Original Poster
Rep: Reputation: Disabled
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?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:31 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration