linux上shell编程实例
linux下shell编程实例echo A is: echo $a num2 echo this is the ${num}nd # this is a test times0
linux下shell编程实例
echo "A is:"
echo $a
num=2
echo "this is the ${num}nd"
# this is a test
times=0
until ["$times"=3];
do
echo "I love linux."
sleep 2
times=`expr $times+1`
done
?
fi
# test for
for((i=1;i<10;i++))
do
res=`expr $i \* $i`
echo $res
done
# test while
num=1
while [ $num -le 10 ]
do
sum=`expr $num \* $num`
echo $sum
num=`expr $num + 1`
done
echo -n "Enter Choice:"
read choice
case "$choice" in
1) echo "Restore";;
2) echo "Backup";;
3) echo "Unload";;
*) echo "Sorry $choice is not a valid choice"
exit 1
esac
?
elif [ -d $i ]
then
echo "$i is a directory"
fi
done
?
?