shell中if语句

read first
echo "$first"
echo $?
if [ $first = 'hello' ]
    then
    echo "right"
    else
    echo "error"
fi
if test $first='hello'
    then
    echo "111111111111111";
fi
content=`ls`
echo $content
who=`who`
echo $who
echo $who >> 1.result
whoami=`whoami`
result=`grep -c $whoami 1.result`
echo "result:" $result;
if [ $result -gt 0 ]
    then
    echo "找到内容"
    else
        echo "木牛"
    fi
if who | grep 'test115'
    then
    echo "yes"
    else
        echo "no"
        fi

mount.sh

  1 who=$1
  2 #echo $who
  3 if test $who = 'company'
  4     then
  5     echo "公司ip";
  6     ip="192.168.99.249";
  7 else
  8     echo "小屋子ip";
  9     ip="192.168.2.112";
 10 fi
 11
 12 echo $ip
 13 mount //$ip/virtual_xp /mnt/virtual_xp
 14 echo "mount xp success"

    A+
发布日期:2013年12月08日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: