1845261 Members
3311 Online
110244 Solutions
New Discussion

scripts help

 
SOLVED
Go to solution
Kenn Chen
Advisor

scripts help

i would like to do monipulation of my script.

eg. count=5
line_count= count - 3
but failed why ??
Cyber Zen
3 REPLIES 3
Jdamian
Respected Contributor
Solution

Re: scripts help

Arithmetic expressions can be used in a script by means of double brackets pair
$(( ??? )) pair

For example:

COUNT=3
OTHER=$(($COUNT - 1))
Bill McNAMARA_1
Honored Contributor

Re: scripts help

count=5
val= expr $count - 3
echo $val

The val is taken as a string not as an int.

Later,
Bill
It works for me (tm)
Magdi KAMAL
Respected Contributor

Re: scripts help

Hi Idris,

val1=5
Val1=`expr $val1 - 2`

Do not forget back quotes for command evaluation.

Magdi