如何使用 ncdu 查看当前文件夹包含的文件数量(不包括子文件夹中的文件)?

如何使用 ncdu 查看当前文件夹包含的文件数量(不包括子文件夹中的文件)?

我用NCDU浏览一些文件夹。如何查看当前文件夹将包含的文件数量(不包括子文件夹中的文件)?


默认情况下,在 ncdu 中,当前文件夹包含的文件数包括位于子文件夹中的文件:

在此输入图像描述

我知道其他命令,例如(作者:玛雅·皮乔特卡):

 find . -maxdepth 1 -type f | wc -l

但我想知道是否ncdu可以做到。

答案1

ncdu <pathToScan> --exclude=<excludeDirA> --exclude=<excludeDirB> --exclude=<excludeDirC>

例子:sudo ncdu / --exclude=/dev --exclude=/Applications

有关更多选项,这里是ncdu扫描文档:

 Scan Options

These options affect the scanning progress, and have no effect when 
importing directory information from a file.


-x  Do not cross filesystem boundaries, i.e. only count files and directories on the same filesystem as the
           directory being scanned.

   --exclude PATTERN
       Exclude files that match PATTERN. The files will still be displayed by default, but are not counted
       towards the disk usage statistics. This argument can be added multiple times to add more patterns.

   -X FILE, --exclude-from FILE
       Exclude files that match any pattern in FILE. Patterns should be separated by a newline.

   --exclude-caches
       Exclude directories containing CACHEDIR.TAG.  The directories will still be displayed, but not their
       content, and they are not counted towards the disk usage statistics.  See
       http://www.brynosaurus.com/cachedir/

   -L, --follow-symlinks
       Follow symlinks and count the size of the file they point to. As of ncdu 1.14, this option will not follow
       symlinks to directories and will count each symlinked file as a unique file (i.e. unlike how hard links
       are handled). This is subject to change in later versions.

来源

手册页

相关内容