LinuxQuestions.org
Help answer threads with 0 replies.
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, 10:02 PM   #1
hchoonbeng
LQ Newbie
 
Registered: Sep 2008
Posts: 15

Rep: Reputation: 0
problem with expression


Hi 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, 10:39 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Is this inside a bash script?
Please show entire script.
In any case, if you want the results of a cmd (inc expr calc), use backquotes (`), not single(') or double (") quotes.
eg

num_64k=`expr free_mem*0.85/134217728`

http://tldp.org/LDP/abs/html/commandsub.html
 
Old 10-09-2008, 04:26 AM   #3
hchoonbeng
LQ Newbie
 
Registered: Sep 2008
Posts: 15

Original Poster
Rep: Reputation: 0
the full script look like this:

#!/bin/bash

free_mem="bootinfo -r"

num_4k=`expr free_mem*0.75/268435456`
num_64k=`expr free_mem*0.85/268435456`

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

echo $num_seg_4k

for i in 1 4 8
do
sed -n s/width=[0-9]*/width=$i/p default

for j in 25 100
do
sed -n s/num_oper=[0-9]*/num_oper=$j/p default
# hxemem64 /dev/mem0 OTH /usr/lpp/htx/rules/reg/hxemem64/default
done
done

but i still encountered the following errors:

sed: 0602-404 Function s/num_seg_4k=[0-9]*/num_seg_4k=free_mem*0.75/268435456/p cannot be parsed.
sed: 0602-404 Function s/num_seg_64k=[0-9]*/num_seg_64k=free_mem*0.85/268435456/p cannot be parsed.

what happen?
 
Old 10-09-2008, 05:09 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Quote:
In any case, if you want the results of a cmd (inc expr calc), use backquotes (`), NOT single(') or double (") quotes.
free_mem="bootinfo -r"

will not work
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
perl regular expression problem true_atlantis Programming 4 05-27-2009 07:35 AM
regular expression [tT]h* sycamorex Programming 3 01-15-2008 05:43 PM
PHP PRCE Regular Expression problem x_terminat_or_3 Programming 4 09-11-2007 05:09 PM
having problem in writing regular expression in tcl mohtasham1983 Programming 1 10-29-2006 02:29 PM
OpenOffice regular expression filtering problem JAB4ever Linux - Software 3 12-08-2004 05:42 PM


All times are GMT -5. The time now is 09:26 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration