#!/bin/bash
#你值得收藏的四则表达式运算.
val1=1
val2=1
val3=1
val4=1
val5=1 val6=1 let
val7=1
((val1++))
val3=$ (($val 3+1))
val4= ' expr $val 4 + 1 '
val5= ' bc<<< $val 5+1 '
val6= ' echo ' $val 6+1 ' |BC '
val7=$[$val 7+1]
echo ' val1= ' $val 1
echo ' val2= ' $val 2
echo ' val3= ' $val 3
echo ' val4= ' $val 4< C19/>echo ' val5= ' $val 5
echo ' val6= ' $val 6
echo ' val7= ' $val 7
You should understand the conditional control statement.
#!/bin/bash
#
val=1
if test $val-eq 1;then
echo "Hello word!"
Fi
#!/bin/bash
#
val=1
If [$val-eq 1];then
echo "Hello word!"
Fi
#!/bin/bash
#
val=1
[$val-eq 1] && {
echo "Hello word!"
}
#[]//does not support regular expressions, it is a system command.
#[[]]//supports regular expressions, but not system commands.
#!/bin/bash
val=1
[[$val-eq 1]] && {
echo "Hello word!"
}
#!/bin/bash #输入一个用户判断该用户是否存在. #read-P "Please input your User:" User #a = ' cut-d ': "-f1/etc/passwd|
grep ' $USER ' while true do 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" ' fi done