名字
du - 报告磁盘空间使用情况
总览
du [options] [file...]
POSIX 选项: [-askx]
GNU 选项 (最短格式):
[-abcDhHklLmsSxX] [--block-size=size] [--exclude=pattern] [--max-depth=n] [--help] [--version] [--]
描述
du 报告指定的文件已使用的磁盘空间的总量,包括在层次结构中以这些以指定文件为根的目录在内。这里的“已使用的磁盘空间”意思为指定的文件下的整个文件层次结构所使用的空间。
在没给定参数的情况下,du 报告当前目录所使用的磁盘空间。
POSIX 细节
输出结果在缺省时以512字节为计数单位,若给以 -k 选项,则以 1024字节为计数单位。
GNU 细节
(在没有用选项指定计数单位的情况下)输出结果以1024字节为计数单位,但不包括由于设置了环境变量POSIXLY_CORRECT而跟从POSIX 标准的情况。
POSIX 选项
- -a
- 显示对涉及到的所有文件的统计,而不只是包含子目录。
- -k
- 用1024字节作为计数单位,替代缺省时512字节的计数单位。
- -x
- 只输出指定参数的实际使用空间,而不包括其下的子目录。
- -s
- 只统计指定参数的在同一设备上所使用的空间。
GNU 选项
- -a, --all
- 显示对所有文件的统计,而不只是包含子目录。
- -b, --bytes
- 输出以字节为单位的大小,替代缺省时1024字节的计数单位。
- --block-size=size
- 输出以块为单位的大小,块的大小为 size 字节。( file- utils-4.0 的新选项)
- -c, --total
- 在处理完所有参数后给出所有这些参数的总计。这个选项被用给出指定的一组文件或目录使用的空间的总和。
- -D, --dereference-args
- 引用命令行参数的符号连接。但不影响其他的符号连接。这对找出象 /usr/tmp 这样的目录的磁盘使用量有用, /usr/tmp 等通常是符号连接。 译住:例如在 /var/tmp 下建立一个目录test, 而/usr/tmp 是指向 /var/tmp 的符号连接。du /usr/tmp 返回一项 /usr/tmp , 而 du - D /usr/tmp 返回两项 /usr/tmp,/usr/tmp/test。
- --exclude=pattern
- 在递归时,忽略与指定模式相匹配的文件或子目录。模式可以是任何 Bourne shell 的文件 glob 模式。( file- utils-4.0 的新选项)
- -h, --human-readable
- 为每个数附加一个表示大小单位的字母,象用M表示二进制的兆字节。
- -H, --si
- 与 -h 参数起同样的作用,只是使用法定的 SI 单位( 用 1000的幂而不是 1024 的幂,这样 M 代表的就是1000000 而不是 1048576)。(fileutils-4.0 的新选项)
- -k, --kilobytes
- 输出以1024字节为计数单位的大小。
- -l, --count-links
- 统计所有文件的大小,包括已经被统计过的(作为一个硬连接)。
- -L, --dereference
- 引用符号连接(不是显示连接点本身而是连接指向的文件或目录所使用的磁盘空间)。
- -m, --megabytes
- 输出以兆字节的块为计数单位的大小(就是 1,048,576 字节)。
- --max-depth=n
- 只输出命令行参数的小于等于第 n 层的目录的总计。 --max-depth=0的作用同于-s选项。(fileutils-4.0的新选项)
- -s, --summarize
- 对每个参数只显示总和。
- -S, --separate-dirs
- 单独报告每一个目录的大小,不包括子目录的大小。
- -x, --one-file-system
- 忽略与被处理的参数不在同一个文件系统的目录。
- -X file, --exclude-from=file
- 除了从指定的文件中得到模式之外与 --exclude 一样。模式以行的形式列出。如果指定的文件是'-',那么从标准输入中读出模式。(fileutils-4.0 的新选项) GNU 标准选项
- --help
- 在标准输出上输出帮助信息后正常退出。
- --version
- 在标准输出上输出版本信息后正常退出。
- --
- 终结选项列表
缺陷
对于从 HP-UX 系统上以 NFS 方式挂装上的文件,在 BSD 系统上的 du 报告的大小是正确数值的一半;而对于从 BSD 系统上以 NFS 方式挂装上的文件,HP-UX 系统上的 du 报告的大小是正确数值的翻倍。这是 HP-UX 的缺陷导致的,这个缺陷也影响HP-UX的 du 程序。
变量
变量 POSIXLY_CORRECT 确定计数单位的选择。如果没有设置此变量并且环境变量 BLOCKSIZE 的值以‘HUMAN’为前缀,那么,除了 -k 或 -m 选项优先生效的情况,计数单位的行为同于 -h 选项。变量 LANG、LC_ALL、LC_CTYPE 和 LC_MESSAGES 的意义和字面上一样。
遵循的标准
POSIX 1003.2
注意事项
本页面描述的 du 可在 fileutils-4.0 包中找到,其他版本可能有细微的不同。把更正和补充以邮件的形式发送到 aeb@cwi.nl。向 file utils-bugs@gnu.ai.mit.edu.报告程序存在的缺陷。
#p#
NAME
du - estimate file space usage
SYNOPSIS
du [OPTION]... [FILE]...
DESCRIPTION
Summarize disk usage of each FILE, recursively for directories.
Mandatory arguments to long options are mandatory for short options too.
- -a, --all
- write counts for all files, not just directories
- --apparent-size
- print apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger due to holes in (`sparse') files, internal fragmentation, indirect blocks, and the like
- -B, --block-size=SIZE use SIZE-byte blocks
- -b, --bytes
- equivalent to `--apparent-size --block-size=1'
- -c, --total
- produce a grand total
- -D, --dereference-args
- dereference FILEs that are symbolic links
- -H
- like --si, but also evokes a warning; will soon change to be equivalent to --dereference-args (-D)
- -h, --human-readable
- print sizes in human readable format (e.g., 1K 234M 2G)
- --si
- like -h, but use powers of 1000 not 1024
- -k
- like --block-size=1K
- -l, --count-links
- count sizes many times if hard linked
- -L, --dereference
- dereference all symbolic links
- -P, --no-dereference
- don't follow any symbolic links (this is the default)
- -0, --null
- end each output line with 0 byte rather than newline
- -S, --separate-dirs
- do not include size of subdirectories
- -s, --summarize
- display only a total for each argument
- -x, --one-file-system
- skip directories on different filesystems
- -X FILE, --exclude-from=FILE
- Exclude files that match any pattern in FILE.
- --exclude=PATTERN Exclude files that match PATTERN.
- --max-depth=N
- print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is the same as --summarize
- --help
- display this help and exit
- --version
- output version information and exit
SIZE may be (or may be an integer optionally followed by) one of following: kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
PATTERNS
PATTERN is a shell pattern (not a regular expression). The pattern ? matches any one character, whereas * matches any string (composed of zero, one or multiple characters). For example, *.o will match any files whose names end in .o. Therefore, the command
- du --exclude='*.o'
will skip all files and subdirectories ending in .o (including the file .o itself).
AUTHOR
Written by Torbjorn Granlund, David MacKenzie, Paul Eggert, and Jim Meyering.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
COPYRIGHT
Copyright © 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
SEE ALSO
The full documentation for du is maintained as a Texinfo manual. If the info and du programs are properly installed at your site, the command
- info coreutils du
should give you access to the complete manual.