#!/bin/bash
a= vmquery -b -pn Scratch |grep -i ACS |grep -iw hcart3|wc -l
if [ "$a" -lt 20 ] ; then
mailx -s "BSPRD267 Scratch Count" my@email
else
echo "Scratch count is $a"
fi
获取错误消息如下: -
./ scratch.sh:line 3:[::期望整数表达式
答案 0 :(得分:1)
要评估命令并将结果存储到变量中,您需要执行var=$(command)
。在你的情况下:
a=$(vmquery -b -pn Scratch |grep -i ACS |grep -iw hcart3|wc -l)