在shell中查找非零大小的文件

我需要得到一个目录中的非零大小的文件的名称列表。 这应该是在一个shell脚本,所以bash(或Perl一行)将是理想的。

find /path/to/dir -type f -size +0 
 find /searchdir -type f -size +0c 

将在/searchdir及以下版本中查找大小为一个或多个字节的文件。

只有壳牌,避免find,没有recursion到子目录:

bash(未设置GLOBIGNORE):

 for file in .* *; do test . = "$file" && continue test .. = "$file" && continue # if you just want real files, no symlinks # test -L "$file" && continue test -f "$file" || continue test -s "$file" || continue # here do what you want with what is left done