要求:
想删除 path/sppjk.com/runtime/, path/fun.sppjk.com/runtime/,path/fans.sppjk.com/runtime/* 文件
第一种写法:
#!/bin/bash
# 清理指定目录下的文件
cleanup_directory() {
directory=$1
echo "Cleaning up $directory"
rm -rf $directory/*
}
# 清理每个目录
cleanup_directory "path/www.sppjk.com/runtime"
cleanup_directory "path/fun.sppjk.com/runtime"
cleanup_directory "path/fans.sppjk.com/runtime"
echo "Cleanup complete"
第二种写法:
#!/bin/bash
# 清理指定目录下的文件
cleanup_directory() {
directory=$1
echo "Cleaning up $directory"
#rm -f $directory/*
find $directory -type f -delete
}
# 清理每个目录
cleanup_directory "path/www.sppjk.com/runtime/cache"
cleanup_directory "path/www.abclsp.com/runtime/cache"
cleanup_directory "path/lj.sppjk.com/runtime/cache"
cleanup_directory "path/cl.sppjk.com/runtime/cache"
cleanup_directory "path/lb.sppjk.com/runtime/cache"
cleanup_directory "path/sm.sppjk.com/runtime/cache"
echo "Cleanup complete"
评论 (0)