Dru*_*n M 38 linux terminal command-line command-line-interface du
如何从ncdu扫描中排除目录?
我在man ncdu页面中找不到信息。
这样做时,ncdu -x /它扫描了我的/home/tmp目录将近一个小时。
谢谢你的帮助。
Dru*_*n M 54
根据@subtleseeker 在评论中的要求,我将分享在执行 ncdu 命令时如何排除目录。
基本上ncdu与命令具有相同的命令行选项du,因此要排除目录,只需使用:
--exclude /dir/path
Run Code Online (Sandbox Code Playgroud)
例如: ncdu -x / --exclude /home/tmp
排除多个目录: ncdu -x / --exclude /home/tmp --exclude /var/log
等等。
请注意,您应该避免尾部斜杠(使用/home/tmpNOT /home/tmp/),否则它将无法实际排除目录。
avi*_*amg 13
NCDU - ncdu(NCurses Disk Usage)是著名的“du”的基于curses的版本,提供了一种快速查看哪些目录正在使用您的磁盘空间的方法。
作为扫描选项的一部分,您可以通过以下公式排除一个或多个目录来更准确并节省时间:
ncdu <pathToScan> --exclude=<excludeDirA> --exclude=<excludeDirB> --exclude=<excludeDirC>
Run Code Online (Sandbox Code Playgroud)
例如:
sudo ncdu / --exclude=/dev --exclude=/Applications
Run Code Online (Sandbox Code Playgroud)
有关更多选项,请附上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.
Run Code Online (Sandbox Code Playgroud)