1

我需要检查我的文件系统是否存在,如果确实存在,则其中有 300 MB 的空间。

到目前为止我所拥有的:

if [ "$(df -m /opt/IBM | grep -vE '^Filesystem' | awk '{print ($3)}')" < "300" ]
then
echo "not enough space in the target filesystem"
exit 1
fi

这会引发错误。我真的不知道我在 shell 中做什么。

我的最高优先级是 AIX,但我也在努力让它为 HP 和 Sun 工作。

请帮忙。

-亚历克斯

4

2 回答 2

1

这是我开始工作的代码。

if [ "$(df -m /opt/IBM/ITM | awk 'NR==2{print ($3)}')" -lt "300" ]
then
    echo "not enough space in the target filesystem"
    exit 1
fi
于 2010-03-22T19:44:54.897 回答
0

发布错误怎么办?无论如何,请尝试以下语法,即。双括号,没有双引号:

if [[ $(...) < 300 ]]; then
    ...
fi

man bash

[[ 表达 ]]

根据条件表达式表达式的计算返回状态 0 或 1。

于 2010-03-22T19:19:51.700 回答