Shell script [Operational expressions, conditional control statements], shell expressions
#! /Bin/bash # The four expressions you deserve to add to your favorites. Val1 = 1val2 = 1val3 = 1val4 = 1val5 = 1val6 = 1val7 = 1let val1 ++ (val2 ++) val3 = $ ($ val3 + 1 )) val4 = 'expr $ val4 + 1' val5 = 'bc <$ val5 + 1 'val6 = 'echo "$ val6 + 1" | bc 'val7 = $ [$ val7 + 1] echo 'val1 = '$ val1echo 'val2 =' $ val2echo 'val3 = '$ val3echo 'val4 =' $ val4echo 'val5 = '$ val5echo 'val6 =' $ val6echo 'val7 = '$ val7
You should understand the condition control statements.
#! /Bin/bash # val = 1if test $ val-eq 1; thenecho "hello word! "Fi #! /Bin/bash # val = 1if [$ val-eq 1]; thenecho "hello word! "Fi #! /Bin/bash # val = 1 [$ val-eq 1] & {echo "hello word! "} # [] // Does not support regular expressions. It turns out to be a system command. # [[] // Regular expressions are supported, but not system commands. #! /Bin/bashval = 1 [[$ val-eq 1] & {echo "hello word! "}
#! /Bin/bash # enter a user to determine whether the user exists. # Read-p "please input your user:" USER # a = 'cut-d ": "-f1/etc/passwd | grep" $ USER "while truedo if [" $ USER "=" $ a "]; then echo" yes! This user is exit !!! "Break else echo" this user no exit !!! "Read-p" please input it again: "USER a = 'cut-d": "-f1/etc/passwd | grep" $ USER "'fidone
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.