i am new to shell programming, currently using redhat linux of version 2.4.20-8. i have problem in executing expr command in the following shell script
$ x=5 $ x='expr $x + 1' $ echo $x
the output is displaying always expr $x + 1
Pls guide me for the above query
You need to use back tics not single quotes
x=`expr $x + 1`
I tried to use expr for multiplication, but got an error. I used '*' symbol. Can you tell me what's the problem, or if there is another way? Thanks
escape the * it is a shell metacharacter
a=$( expr 13 \* 3) # or a=`expr 13 \* 3`