echo 'expr 2 +3'
prints expr 2 + 3
(instead of printing 5)
I had read this in book as well as online that within single quotes the expression is evaluated, but on running it is being printed as it is. Is there any dependence on shell . Well, I have tried on Bourne and Korn shell and its not working . Can u Give me some alternative for this and tell me the reason why it is not working?

You're getting the quote character confused with the backtick character. If you run

echo `expr 2 + 3`

you'll get the expected output.

Alternatively, you can also use $(command) as well, which has the same effect:

echo $(expr 2 + 3)

echo ' expr 2 + 3' is not working. i cannot figure out why?? Well thanks for the alternative answer. It worked out.

why? because it shouldn't.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.