请帮我看看这个SHELL脚本有什么问题
#!/bin/shhzc=`df|awk'{print$4}\'|grep%|cut-b1-2`cd/root/CESHIhzc/binhzc2=`ls-lt|awk'{...
#!/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>=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
运行以后他报 Try `rm --help' for more information.
rm: missing operand
这个错误 谢谢!!求详细 展开
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>=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
运行以后他报 Try `rm --help' for more information.
rm: missing operand
这个错误 谢谢!!求详细 展开
展开全部
你好,你这个脚本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
#!/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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询