#! / bin / sh
# input two numbers a, b
read a
read b
if [a> b]
then
echo "a = $ a"
echo "b = $ b"
echo "a> b"
else
echo "a
input or the input 4,3 3,4
Why , will not enter a ------ Solution --------------------------- -----------------
size compared with
-eq
-gt
-lt
-le
-ge
> indicates redirection when you enter 3,4 , the current directory will be more than one file , " 4" , enter 4,3 , it will be more than one file " 3 ."
------ Solution ---------------------------------------- ----
If you want to compare numerical size if [a> b], it should be $ a and $ b, and [ ] is not > than the size of the role , [ ] ; into [ [ ] ] , or use the -gt,-lt
------ Solution ---------------------- ----------------------
regulatory issues , Linux is defined <> as the input and output redirection, the comparative figures for the size -eq equal ;-gt greater ;-lt less ;-le less than or equal ;-ge greater than or equal ;-ne not equal . Comparison should be read into the variable $ a, $ b, if [$ a-gt $ b].
------ Solution ---------------------------------------- ----
add:
[] which can be used > to , but need to escape . ( And it is a string comparison , not a numeric comparison. )
[root @ ~] # [a \> b] && echo yes | | echo no
no
[root @ ~] # [c \> b] && echo yes | | echo no
yes
------ For reference only --------------------------------- ------
thank
------ For reference only ---------------------------- -----------
add:
[] which can be used > to , but need to escape . ( And it is a string comparison , not a numeric comparison. )
[root @ ~] # [a \> b] && echo yes | | echo no
no
[root @ ~] # [c \> b] && echo yes | | echo no
yes Thank
------ For reference only --------------------------------- ------
add:
[] which can be used > to , but need to escape . ( And it is a string comparison , not a numeric comparison. )
[root @ ~] # [a \> b] && echo yes | | echo no
no
[root @ ~] # [c \> b] && echo yes | | echo no
yes Thank
------ For reference only --------------------------------- ------
forehead , on the top floor , the brothers too have patience , this proposal facie shell of the book, did not figure out the syntax is completely
------ For reference only - --------------------------------------
add:
[] which can be used > to , but need to escape . ( And it is a string comparison , not a numeric comparison. )
[root @ ~] # [a \> b] && echo yes | | echo no
no
[root @ ~] # [c \> b] && echo yes | | echo no
yes
long time not so used to have forgotten , thanks to complement
没有评论:
发表评论