这是我的 bash 脚本的一部分:
# Checking disk
for disk in $disks
do
# Creating a array with results
declare -a status=(`smartctl -a -d ata $disk | awk '/Reallocated_Sector_Ct/ || /Seek_Error_Rate/ { print $2" "$NF }'`)
# Checking that we do not have any Reallocated Sectors
if [ "${status[1]}" -ne 0 ]
then
echo "$mname Warning: Disk $disk has errors! ${status[0]} ${status[1]} ${status[2]} ${status[3]}. Following complete smartctl output." >> diskerror.log
smartctl -a -d ata $disk >> $logloc/diskerror.log
failed=("${failed[@]}" "$disk")
sendm="1"
fi
done
当我运行脚本时,bash 返回以下错误:disk_status.sh: line 38: [: : integer expression expected
错误行是:if [ "${status[1]}" -ne 0 ]
有人可以帮助解决这个错误吗?