运行环境:Ubuntu12.04 bin/bash
1.比较两个数的大小
#!bin.bash #script4.4.sht echo "Enter the first integer:" read first echo "Enter the second integer:" read second if [ "$first" -gt "$second" ] then echo "$first is greater than $second" elif [ "$first" -lt "$second" ] then echo "$first is less than $second" fi
#!bin/bash #script4.3.sht echo -n "Enter your login name: " read name if [ "$name" = "$USER" ]; then echo "Hello,$name,how are you today?" else echo "If you are not user,who are you?" fi
3.求若干数中的最小值
#!bin/bash #script 4.8.sht smallest=10000 for i in 12 5 18 58 -3 80 do if test $i -lt $smallest then smallest=$i fi done echo " The smallest number is :$smallest"
版权声明:本文为博主原创文章,未经博主允许不得转载。