Du

来自 ChinaUnix Wiki

Linux命令:du

功能说明:显示目录或文件的大小。
语  法:du [-abcDhHklmsSx][-L <符号连接>][-X <文件>][--block-size][--exclude=<目录或文件>][--max-depth=<目录层数>][--help][--version][目录或文件]
补充说明:du会显示指定的目录或文件所占用的磁盘空间。
参  数:
-a或-all   显示目录中个别文件的大小。
-b或-bytes   显示目录或文件大小时,以byte为单位。
-c或--total   除了显示个别目录或文件的大小外,同时也显示所有目录或文件的总和。
-D或--dereference-args   显示指定符号连接的源文件大小。
-h或--human-readable   以K,M,G为单位,提高信息的可读性。
-H或--si   与-h参数相同,但是K,M,G是以1000为换算单位。
-k或--kilobytes   以1024 bytes为单位。
-l或--count-links   重复计算硬件连接的文件。
-L<符号连接>或--dereference<符号连接>   显示选项中所指定符号连接的源文件大小。
-m或--megabytes   以1MB为单位。
-s或--summarize   仅显示总计。
-S或--separate-dirs   显示个别目录的大小时,并不含其子目录的大小。
-x或--one-file-xystem   以一开始处理时的文件系统为准,若遇上其它不同的文件系统目录则略过。
-X<文件>或--exclude-from=<文件>   在<文件>指定目录或文件。
--exclude=<目录或文件>   略过指定的目录或文件。
--max-depth=<目录层数>   超过指定层数的目录后,予以忽略。
--help   显示帮助。
--version   显示版本信息。


英文版本,欢迎翻译:

ABOUT DU

Tells you how much space a file occupies.

SYNTAX

du [-a] [-k] [-s] [-d] [-L] [-o] [-r] [-x] directories

-a Displays the space that each file is taking up.

-k Write the files sizes in units of 1024 bytes, rather than the default 512-byte units.

-s Instead of the default output, report only the total sum for each of the specified files.

-d Do not cross filesystem boundaries. For example, du -d / reports usage only on the root partition.

-L Process symbolic links by using the file or directory which the symbolic link references, rather than the link itself.

-o Do not add child directories' usage to a parent's total. Without this option, the usage listed for a particular directory is the space taken by the files in that directory, as well as the files in all directories beneath it. This option does nothing if -s is used.

-r Generate messages about directories that cannot be read, files that cannot be opened, and so forth, rather than being silent (the default).

-x When evaluating file sizes, evaluate only those files that have the same device as the file specified by the file operand. directories Specifies the directory or directories.


EXAMPLES

du -s *.txt - Would report the size of each txt file in the current directory. Below is an example of the output.

8 file1.txt 8 file2.txt 10 file3.txt 2 file4.txt 8 file5.txt 8 file6.txt




中文翻译:


关于DU


得知文件占用多大的空间.


语法规则

du [-a] [-k] [-s] [-d] [-L] [-o] [-r] [-x] directories

-a 显示每一个文件所占去的空间.

-k 输出文件的大小以1024个字节为单位,而不是默认的512字节.

-s 代替默认的输出,仅报告所指定的文件的总大小.

-d 不会混合文件系统范围. 比如, du -d / 仅报告根分区使用的空间.

-L 通过使用符号链接所指定的文件或者目录来处理符号链接,而不是符号链接本身.

-o 不添加字目录的使用空间到父目录的总使用空间里.若不指定该选项,列出的指定目录的使用空间是该目录内的文件所占用的空间,也就是所有处于该目录下的文件大小.如果使用了-s 选项,那么该选项不会产生任何作用.

-r 生成关于不能读取的目录和不能打开的文件的信息等等,而不是无提示(默认的).

-x 检测文件大小时,仅仅通过文件操作来检测那些和指定文件具有相同设备的文件.多目录指定单目录或者多目录.


应用举例:

du -s *.txt - 将报告当前目录下的所有txt类型的文件大小,下边是一个输出的样本.

8 file1.txt 8 file2.txt 10 file3.txt 2 file4.txt 8 file5.txt 8 file6.txt

个主工具