if结构练习
#!bin/bash
#if语句的测试
if [ "$shell"="/bin/bash" ];then
echo "your login shell is the bash"
else
echo "your login shell is not bash but$shell"
fi
for结构练习
#!bin/bash
#for语句的测试
for var in A B C ;do
echo "var is $var"
done
while结构练习
#!bin/bash
myvar=1
while [ $myvar -le 10 ]
do
echo $myvar
myvar=$(( $myvar + 1 ))
done
until结构练习
#!bin/bash
myvar=1
while [ $myvar -gt 10 ]
do
echo $myvar
myvar=$(( $myvar + 1 ))
done
Linux Shell 中写循环时,常常要用到变量的自增,下面总结了五种整形变量自增的方法:
1、i='expr $i + 1';
2、let i+=1;
3、((i++));
4、i=$ [ $i+1 ];
5、i=$(( $i + 1 ))