你好,你这个脚本awk的用法有点错误('后面不应该加\),另外while循环中比较运算符运用不对.正确的脚本如下:
#!/bin/sh
hzc=`df|awk '{print $4}'|grep %|cut -b 1-2`
cd /root/CESHIhzc/bin
hzc2=`ls -lt|awk '{print $9}'|tail -1`
if test $hzc -gt 19
then
while [ hzc -ge 18 ]
do
rm $hzc2
hzc=`df|awk '{print $4}'|grep %|cut -b 1-2`
hzc2=`ls -lt|awk '{print $9}'|tail -1`
done
else
echo "$hzc"
fi