Hi, On Wed, 26 Oct 2005, Christian Boltz wrote:
Am Dienstag, 25. Oktober 2005 23:50 schrieb Eberhard Moenkeberg:
On Tue, 25 Oct 2005, Robert Schiele wrote:
On Tue, Oct 25, 2005 at 10:13:09PM +0200, Eberhard Moenkeberg wrote:
On Tue, 25 Oct 2005, Pascal Bleser wrote:
[...]
Right. Topped.
But there is a big problem with that solution anyway: It assumes that MemTotal is the first line in /proc/meminfo. If one decides to reorder this table in the kernel or add some headline all your scripts using this solution will break.
Surely. It was just a sports exercise.
If I would need it, I would do
grep ^MemTotal /proc/meminfo | (read a b c; echo $b )
and here bash needs the "(...)" to force the subprocess forking at the right point...
No, it does *not* need a subprocess. You just need to expand the pipe ;-)
grep ^MemTotal /proc/meminfo | { read a b c; echo $b ; }
Topped again :-)
Not really; the top solution does not call ANY external program.
If you (or other readers) want an explanation about expanding the subshell or even need to "export" variables from subshells, have a look at my homepage [1]: http://www.cboltz.de/de/linux/bash/?os (german) http://www.cboltz.de/en/linux/bash/?os (english)
Thanks; but just bookmarked now - too late tonight.
Oh, there's another way ;-) set -- `grep ^MemTotal /proc/meminfo` ; echo $2
This time, I topped myself ;-)
Just using bash intrinsics is the skill.
Anybody out there who wants to top one of my solutions? *eg*
BTW: Christoph just told me that he is really upset about the ignorance of all the readers here. He had done all his best to cat a good MemTotal value from a real system, but noone did realize it...
Now as you mention it - "MemTotal: 526525152 kB" (500 GB) is something I'd like to have ;-) (even all machines I have here together don't have that much _hard disk_ space...)
You know, a man's ram size is directly proportional to the size of his ... Or was that reverse proportional? Cheers -e -- Eberhard Moenkeberg (emoenke@gwdg.de, em@kki.org)