條件,我在linux工作的一些bash腳本,我只是想比較兩個數的整數。一個是磁盤大小,另一個是限制。我如何使用Linux cmd,然後如下圖所示將其存儲在一個變量獲得磁盤大小,比較使用IF在bash腳本
declare -i output
output= df -h | grep /beep/data| awk '{ printf ("%d",$5)}'
echo "$output" # Got 80 here
limit = 80
if [ $output -eq $limit ];
then
fi
上運行,我得到了以下錯誤:
line 27: [: -eq: unary operator expected"
這是你跑了確切的代碼?不像你已經越過第二行 – Fazlin
你'df'線看起來不錯,我可以從我的測試結果確認你確定你沒有圍繞'='原代碼空間。 – sjsam
爲什麼無法複製和粘貼實際的代碼? – sjsam