Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I write

expr 123 \< 5  

the result is correct (0) because expr evaluates two integers.
Also

expr 123. \< 5  

gives the expected result (1) because now it compares two strings.
But

expr "123" \< 5  

gives 0 (I expected 1, as before)
Why?

share|improve this question

1 Answer 1

up vote 1 down vote accepted
expr 123 \< 5

and

expr "123" \< 5

give the same answer because what the expr command sees in its program arguments is exactly the same in both cases. Arguments 1, 2, and 3 are 123, <, and 5 in both cases.

Use /bin/echo instead of expr to see this more clearly.

Escaping and quoting are handled by your shell. What commands see once run is what your command line ends up as after the shell has handled all redirections, expansions, and subtitutions, and removed all quoting.

share|improve this answer
    
Thank you... This was driving me crazy –  user2431763 Jan 28 at 19:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.