shell中if语句

发布时间:2013-12-08 17:48:02 阅读:1044次

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"

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询
下一篇:find exec

转载请注明:shell中if语句 出自老鄢博客 | 欢迎分享