-->
当前位置:首页 > 题库

主观题:h10.编写个shell 脚本将/boot/grub/目录下大于100K 的文件转移到/opt 目录下

Luz4年前 (2022-10-05)题库442
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