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?
shraddha_gupta 0 Newbie Poster
Recommended Answers
Jump to PostYou'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)
All 3 Replies
John A 1,896 Vampirical Lurker Team Colleague
shraddha_gupta 0 Newbie Poster
DimaYasny 180 Godmode enabled Team Colleague Featured Poster
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.