LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 02-19-2016, 11:30 AM   #1
kernkraftx
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, 12:47 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,147

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
This should get you started:
Code:
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, 01:12 PM   #3
kernkraftx
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?
 
  


Reply



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



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:35 PM.

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