我正在尝试制作一个 bash 脚本,在不使用 find 命令的情况下查找并删除目录(包括子目录)中的空文件。
这是使用 find 命令的脚本的一部分,但我不确定如何在不使用 find 的情况下转换此行。
find . -type f -empty -delete
试试这个代码:
# enable recursive globstar matching
shopt -s globstar
# directory to delete files from
dir="/tmp"
# loop through files recusively
for f in ${dir}/* ${dir}/**/* ; do
# check if file is empty
if [ ! -s "$f" ]; then
# remove file
rm "$f"
fi
done
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)