shell判断

[ -d "$LTPROOT/testcases/bin" ] ||
{
    echo "FATAL: LTP not installed correctly"
    echo "INFO:  Follow directions in INSTALL!"
    exit 1
}

        if [ "$BYTES" -eq 0 ]; then
            BYTES=$((256 * 1024 * 1024))
        fi
>/dev/null 2>&1 &

cat <<-EOF >&1
            WARNING: The use of -x can cause unpredictable failures, as a
                     result of concurrently running multiple tests designed
                     to be ran exclusively.
                     Pausing for 10 seconds..."
  EOF

if [ “$RANDOMRUN” != “0” ]; then
echo “not eq 0”
fi

if ! find “$DMESG_DIR” -size 0 -exec rm {} + ; then
echo “cd to $DMESG_DIR failed: $?”
fi

如果变量TEST不存在时,则输出 “变量TEST为空!”:

if [ ! "$TEST" ]; then
   echo "变量TEST为空!"
else
   echo "变量TEST不为空值!"
fi

如果wget命令存在:

if which wget >/dev/null 2>&1; then

如果变量TEST存在,输出 “test not empty”
如果chmod操作失败,输出异常:
如果cd进不去(目标不存在),操作失败,则输出异常:

unset SCRATCHDEV
    [ -n "$SCRATCHDEV" ] && \
    {
         cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
         {
             echo "FATAL: unable to create  fsx-linux tests command file"
             exit 1
         }
    }
if [ -n "$TAG_RESTRICT_STRING" ]
    then
        mv -f ${TMP}/alltests ${TMP}/alltests.orig
	    grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
    fi
${LTPROOT}/IDcheck.sh || \
    {
        echo "WARNING: required users and groups not present"
        echo "WARNING: some test cases may fail"
    }

如果变量a为1,或者变量b为1,则输出cat中的输出信息:
如果变量a不能1,而且变量b也不为1,则输出echo "all not

[ "$a" -eq 1 ] || [ "$b" -eq 1 ] && \
    {
    cat <<-EOF >&1
       ###############################################################
            Done executing testcases.
            LTP Version:  $version_date
       ###############################################################
  EOF
    } || echo "all not 1"

[ “$LOOP_DEV” ] && losetup -d $LOOP_DEV

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值