Hello, 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 :-) 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) Oh, there's another way ;-) set -- `grep ^MemTotal /proc/meminfo` ; echo $2 This time, I topped myself ;-) 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...) Regards, Christian Boltz [1] new design still pending because of a problem with IE :-( -- [Debian] für meinen privaten Rechner ist es mir zu konservativ. Da bastel ich gerne mal und wälze mich wollüstig in Featureitis und Versionismus und bin erst glücklich, wenn das System ernst- lich Schaden genommen hat. [Ratti in suse-linux] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]