2010-03-22 78 views
1

我需要檢查我的文件系統是否存在,如果存在,則其中有300 MB的空間。嘗試在Unix上測試文件系統中的空間

我有什麼至今:

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工作。

請幫忙。

-Alex

回答

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 
0

如何發佈錯誤?無論如何,請嘗試以下語法,即。雙括號和沒有雙引號:

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

人的bash

[[表達式]]

返回取決於條件 表達式表達式的求值的0或1的狀態。

+0

該OP可能使用'sh',它沒有'[['。雖然'ksh'確實有它,如果這是使用什麼。 – 2010-04-10 02:11:26