LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-08-2008, 04:10 AM   #1
hchoonbeng
LQ Newbie
 
Registered: Sep 2008
Posts: 15

Rep: Reputation: 0
how to get free memory of the unix system


i try

#!/bin/bash
free_memory = bootinfo -r

x = 'expr $free_memory*10'


why does it complaint -r command not found. but i try the command bootinfo -r in shell its ok
 
Old 10-08-2008, 04:14 AM   #2
indeliblestamp
Member
 
Registered: Feb 2006
Distribution: Fedora
Posts: 341
Blog Entries: 3

Rep: Reputation: 40
Use double quotes when you're storing the value of bootinfo into free_memory.
Code:
free_memory="bootinfo -r"
 
Old 10-08-2008, 04:17 AM   #3
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Assign variables without spaces, and use quotes for multiple words:

free_memory='bootinfo -r'

But I think you want command substitution:

free_memory=$(bootinfo -r)

You can avoid the expr call and use bash built-in arithmetic expansion:

(( x = free_memory * 10 ))
 
Old 10-08-2008, 08:53 PM   #4
hchoonbeng
LQ Newbie
 
Registered: Sep 2008
Posts: 15

Original Poster
Rep: Reputation: 0
i try :

free_mem="bootinfo -r"

num_4k='expr free_mem*0.75/536870912'
num_64k='expr free_mem*0.85/134217728'

sed -n s/num_seg_4k=[0-9]*/num_seg_4k=$num_4k/p default
sed -n s/num_seg_64k=[0-9]*/num_seg_64k=$num_64k/p default

but it give the following error:

sed: 0602-404 Function s/num_seg_4k=[0-9]*/num_seg_4k=expr cannot be parsed.
sed: 0602-404 Function s/num_seg_64k=[0-9]*/num_seg_64k=expr cannot be parsed.


what could be wrong??

thanks
 
Old 10-08-2008, 09:43 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
see my answer to your repeat of this qn in the other thr.
Don't do that again though.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between resident memory,shared memory and virtual memory in system monitor mathimca05 Linux - Newbie 1 11-11-2007 04:05 AM
Free Memory Not Reclaimed By System Sheado Programming 3 09-28-2007 03:38 PM
installed system memory differs from mounted (available) memory landroni Debian 5 08-13-2007 06:43 AM
Does free( ) immediatly free the memory? Rayven Programming 24 11-06-2006 02:24 AM
LXer: Move an entire file system on a live Unix system LXer Syndicated Linux News 0 07-08-2006 05:33 PM

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

All times are GMT -5. The time now is 12:48 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