LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to get free memory of the unix system (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-get-free-memory-of-the-unix-system-674993/)

hchoonbeng 10-08-2008 04:10 AM

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

indeliblestamp 10-08-2008 04:14 AM

Use double quotes when you're storing the value of bootinfo into free_memory.
Code:

free_memory="bootinfo -r"

Mr. C. 10-08-2008 04:17 AM

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 ))

hchoonbeng 10-08-2008 08:53 PM

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

chrism01 10-08-2008 09:43 PM

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


All times are GMT -5. The time now is 09:35 AM.