du 中文man頁面
名字
du - 報告磁盤空間使用情況
總覽
du [options] [file...]
POSIX 選項: [-askx]
GNU 選項 (最短格式):
[-abcDhHklLmsSxX] [--block-size=size] [--exclude=pattern] [--max-depth=n] [--help] [--version] [--]
描述
du 報告指定的文件已使用的磁盤空間的總量,包括在層次結(jié)構(gòu)中以這些以指定文件為根的目錄在內(nèi)。這里的“已使用的磁盤空間”意思為指定的文件下的整個文件層次結(jié)構(gòu)所使用的空間。
在沒給定參數(shù)的情況下,du 報告當(dāng)前目錄所使用的磁盤空間。
POSIX 細(xì)節(jié)
輸出結(jié)果在缺省時以512字節(jié)為計數(shù)單位,若給以 -k 選項,則以 1024字節(jié)為計數(shù)單位。
GNU 細(xì)節(jié)
(在沒有用選項指定計數(shù)單位的情況下)輸出結(jié)果以1024字節(jié)為計數(shù)單位,但不包括由于設(shè)置了環(huán)境變量POSIXLY_CORRECT而跟從POSIX 標(biāo)準(zhǔn)的情況。
POSIX 選項
- -a
- 顯示對涉及到的所有文件的統(tǒng)計,而不只是包含子目錄。
- -k
- 用1024字節(jié)作為計數(shù)單位,替代缺省時512字節(jié)的計數(shù)單位。
- -x
- 只輸出指定參數(shù)的實際使用空間,而不包括其下的子目錄。
- -s
- 只統(tǒng)計指定參數(shù)的在同一設(shè)備上所使用的空間。
GNU 選項
- -a, --all
- 顯示對所有文件的統(tǒng)計,而不只是包含子目錄。
- -b, --bytes
- 輸出以字節(jié)為單位的大小,替代缺省時1024字節(jié)的計數(shù)單位。
- --block-size=size
- 輸出以塊為單位的大小,塊的大小為 size 字節(jié)。( file- utils-4.0 的新選項)
- -c, --total
- 在處理完所有參數(shù)后給出所有這些參數(shù)的總計。這個選項被用給出指定的一組文件或目錄使用的空間的總和。
- -D, --dereference-args
- 引用命令行參數(shù)的符號連接。但不影響其他的符號連接。這對找出象 /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
- 為每個數(shù)附加一個表示大小單位的字母,象用M表示二進(jìn)制的兆字節(jié)。
- -H, --si
- 與 -h 參數(shù)起同樣的作用,只是使用法定的 SI 單位( 用 1000的冪而不是 1024 的冪,這樣 M 代表的就是1000000 而不是 1048576)。(fileutils-4.0 的新選項)
- -k, --kilobytes
- 輸出以1024字節(jié)為計數(shù)單位的大小。
- -l, --count-links
- 統(tǒng)計所有文件的大小,包括已經(jīng)被統(tǒng)計過的(作為一個硬連接)。
- -L, --dereference
- 引用符號連接(不是顯示連接點(diǎn)本身而是連接指向的文件或目錄所使用的磁盤空間)。
- -m, --megabytes
- 輸出以兆字節(jié)的塊為計數(shù)單位的大小(就是 1,048,576 字節(jié))。
- --max-depth=n
- 只輸出命令行參數(shù)的小于等于第 n 層的目錄的總計。 --max-depth=0的作用同于-s選項。(fileutils-4.0的新選項)
- -s, --summarize
- 對每個參數(shù)只顯示總和。
- -S, --separate-dirs
- 單獨(dú)報告每一個目錄的大小,不包括子目錄的大小。
- -x, --one-file-system
- 忽略與被處理的參數(shù)不在同一個文件系統(tǒng)的目錄。
- -X file, --exclude-from=file
- 除了從指定的文件中得到模式之外與 --exclude 一樣。模式以行的形式列出。如果指定的文件是'-',那么從標(biāo)準(zhǔn)輸入中讀出模式。(fileutils-4.0 的新選項) GNU 標(biāo)準(zhǔn)選項
- --help
- 在標(biāo)準(zhǔn)輸出上輸出幫助信息后正常退出。
- --version
- 在標(biāo)準(zhǔn)輸出上輸出版本信息后正常退出。
- --
- 終結(jié)選項列表
缺陷
對于從 HP-UX 系統(tǒng)上以 NFS 方式掛裝上的文件,在 BSD 系統(tǒng)上的 du 報告的大小是正確數(shù)值的一半;而對于從 BSD 系統(tǒng)上以 NFS 方式掛裝上的文件,HP-UX 系統(tǒng)上的 du 報告的大小是正確數(shù)值的翻倍。這是 HP-UX 的缺陷導(dǎo)致的,這個缺陷也影響HP-UX的 du 程序。
變量
變量 POSIXLY_CORRECT 確定計數(shù)單位的選擇。如果沒有設(shè)置此變量并且環(huán)境變量 BLOCKSIZE 的值以‘HUMAN’為前綴,那么,除了 -k 或 -m 選項優(yōu)先生效的情況,計數(shù)單位的行為同于 -h 選項。變量 LANG、LC_ALL、LC_CTYPE 和 LC_MESSAGES 的意義和字面上一樣。
遵循的標(biāo)準(zhǔn)
POSIX 1003.2
注意事項
本頁面描述的 du 可在 fileutils-4.0 包中找到,其他版本可能有細(xì)微的不同。把更正和補(bǔ)充以郵件的形式發(fā)送到 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.