Find maximum positive integer value in Bourne Shell

后端 未结 3 538
隐瞒了意图╮
隐瞒了意图╮ 2021-01-13 16:41

I\'m checking a counter in a loop to determine if it\'s larger than some maximum, if specified in an optional parameter. Since it\'s optional, I can either default the maxi

3条回答
  •  隐瞒了意图╮
    2021-01-13 17:18

    The Bourne shell has no facilities for storing or manipulating numbers - everything is stored as a string. If you are asking about this kind of thing:

    if [ $x -gt $y ]
    

    then that is handled by a separate (in the Bourne shell) executable called test, which has a symbolic link called '['. So your question is really about the limits of the test command, which all the docs I can find seem quite reticent about.

提交回复
热议问题