Ask Your Question
4

Why does the bash conditional statement show that 216 is larger than 0330?

asked 2022-12-06 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-11-23 07:00:00 +0000

nofretete gravatar image

The bash conditional statement treats both numbers as strings because of the leading zero in the second number (0330). In Octal notation, 0330 is equivalent to decimal 216. Therefore, when comparing the two numbers as strings, 216 is considered larger than 0330 because it has a larger numeric value.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-12-06 11:00:00 +0000

Seen: 13 times

Last updated: Nov 23 '21