your_name = “abc”
echo $your_name //输出
readonly ypur_name //只读属性
unset variable_name // 删除变量(不能删除只读变量)

if condition
then
command1
command2
...
commandN
fi
例:
if [ 2 == 2 ];then echo "true";else echo "false";fi
if [ [ 2 > 1 ] ];then echo "true";else echo "false";fi
#比较两个变量的大小并输出不同的值
if [ $a -eq $b ];then echo "equal";elif [ $a -lt $b ];then echo "small";elif [ $a -gt $b ];then echo "big";fi
for var in item1 item2 ... itemN
do
command1
command2
...
commandN
done
例:
for loop in 1 2 3 4 5
do
echo "hello"
done
#循环读取文件内容并输出
for i in $(cat dir.txt);do echo $i;done
while condition
do
command1
done
例:
int = 1
while(( $int<=5 ))
do
echo $int
let "int++"
done
#循环读取文件内容并输出
while read line;do echo $line;done < dir.txt