1.比较两个数的大小:

echo -n "please input the firt number:"
read first
echo -n "please input the second number:"
read second
if [ $first -gt $second ]
       then
       echo "$first is the bigger one !"
       elif [ $first -lt $second ]
               then
               echo "$second is the bigger one !"
               else
               echo "they are equal !"

fi


2.模拟登陆以及下一步:

echo -n "login:"
read name
echo -n "password:"
read -s passwd
if [ $name = "abc" -a $passwd = "123" ]
then
echo "the host and password is right!"
read -n1 -p "do you want to continue (Y/N)?" answer
echo
case $answer in
y | Y)
echo "fine,continue"
;;
n | N)
echo "ok, byebye"
;;
*)
echo "the input is illegal !!!"
;;
esac
#exit 0
else
echo "the name or password is wrong !"
fi


3.另类自然数求和

sumnum.sh

#!/bin/bash

# echo  "please entre your number:"

# read num

for (( i=1;i<=$1;i++ ));

do

echo $i;

done

sh sumnum.sh 100 | echo $[ $( tr '\t' '+') 0]