How do I exclude a directory from ncdu scanning?
I can't found the information in man ncdu
page.
When doing ncdu -x /
it scanned my /home/tmp
directory for almost an hour.
To exclude multiple directories, OR them between parentheses. And, to exclude directories with a specific name at any level, use the -name primary instead of -path .
We can exclude directories by using the help of “path“, “prune“, “o” and “print” switches with find command. The directory “bit” will be excluded from the find search!
without directories — and here it is. Adding -ls or -exec ls -l {} \; would make it like ls -l without directories. find .
ncdu
has the same command line options as the du
command, so to exclude a directory simply use:
--exclude /dir/path
For example: ncdu -x / --exclude /home/tmp
To exclude multiple directories: ncdu -x / --exclude /home/tmp --exclude /var/log
etc.
Note that you should avoid a trailing slash (use /home/tmp
NOT /home/tmp/
) otherwise it will fail to actually exclude the directory.
NCDU - ncdu (NCurses Disk Usage) is a curses-based version of the well-known 'du', and provides a fast way to see what directories are using your disk space.
As part of the scan options, you can be more accurate and save time by excluding directory or directories by this formula:
ncdu <pathToScan> --exclude=<excludeDirA> --exclude=<excludeDirB> --exclude=<excludeDirC>
for example:
sudo ncdu / --exclude=/dev --exclude=/Applications
For more options ,attaching ncdu scan documentation:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With