用shell脚本实现以下功能:

2025-03-04 15:36:38
推荐回答(1个)
回答1:

LZ分类是Windows,那不知道怎么写,只知道在Linux下可以这么写:

#!/bin/bash

E_PARAM=1
E_NOTFOLDER=2
if [[ $# -lt 1 ]]; then
echo "请输入要判断的文件夹"
exit $E_PARAM
if [[ ! -d $1 ]]; then
echo "$1不是文件夹"
exit $E_NOTFOLDER
SIZE=`du -s $1 | awk '{print $1}'`
if [[ $SIZE -gt 20971520 ]]; then
find . -ctime +90 -type f -size 0 -exec rm-fr {} \;
exit 0
建议LZ把要测试的文件夹先备份