1
#!/bin/bash
n=0
for f in *; do
[[ -f "$f" ]] && { echo "$f"; ((n++)); }
done
echo :Number of empty files: $n"
目前它检查当前目录为空文件,我希望它搜索任何目录中的空文件。有任何想法吗?如何使这个脚本工作,但在任何目录而不是当前目录搜索空文件?
#!/bin/bash
n=0
for f in *; do
[[ -f "$f" ]] && { echo "$f"; ((n++)); }
done
echo :Number of empty files: $n"
目前它检查当前目录为空文件,我希望它搜索任何目录中的空文件。有任何想法吗?如何使这个脚本工作,但在任何目录而不是当前目录搜索空文件?
递归搜索在当前目录及以下空文件:
find . -empty -type f
递归列出指定目录空文件及以下,报告中的总
findempty
#!/bin/bash
echo :Number of empty files: `find $1 -empty -type f | tee /dev/tty | wc -l`
例用法
findempty /tmp
示例输出
/tmp/source/fb/b
/tmp/source/fb/a
/tmp/source/fb/c
/tmp/source/fa/b
/tmp/source/fa/a
/tmp/source/fa/c
/tmp/source/fc/b
/tmp/source/fc/a
/tmp/source/fc/c
/tmp/dest/source/fb/b
/tmp/dest/source/fa/b
/tmp/dest/source/fc/b
:Number of empty files: 12