Shell the use condition judgment -n

effect

 [-N parameter] may be used to determine whether the parameter has been assigned

Special Cases

! # / Bin / bash 
# false 
# judge this is a parameter, because no assignment, so the return to true 
IF [-n " $ a " ] 
the then 
    echo to true 
the else 
    echo false 
fi 
# to true 
# judge is "-n $ a "the string that is not empty at this time to true 
# may be used [[-n $ a]] the above case to achieve the effect of 
IF [-n $ a ] 
the then 
    echo to true 
the else 
    echo to false 
Fi 
# to true 
# string grounds ditto 
IF [- Na] 
the then 
    echoto true 
the else 
    echo to false 
Fi 
# to true 
# string, ditto 
IF [- n-] 
the then 
    echo to true 
the else 
    echo to false 
Fi

 

Guess you like

Origin www.cnblogs.com/yangxusun9/p/12607785.html
Recommended