主观题:h10.编写个shell 脚本将/boot/grub/目录下大于100K 的文件转移到/opt 目录下
10.编写个shell 脚本将/boot/grub/目录下大于100K 的文件转移到/opt 目录下。
答案:参考答案:
[root@xuegod63 ~]# cat test.sh
#!/bin/bash
cd /boot/grub
for file in ls /boot/grub
#for file in ls /boot/grub
do
if [ -f $file ]; then
if [ ls -l $file|awk '{print $5}' -gt 10000 ]; then
mv $file /opt/
fi
fi
done
答案:参考答案:
[root@xuegod63 ~]# cat test.sh
#!/bin/bash
cd /boot/grub
for file in ls /boot/grub
#for file in ls /boot/grub
do
if [ -f $file ]; then
if [ ls -l $file|awk '{print $5}' -gt 10000 ]; then
mv $file /opt/
fi
fi
done