du的英文爲:disk usage,含義是磁盤空間使用狀況,功能是逐級進入指定目錄的每個子目錄並顯示該目錄佔用文件系統數據塊的狀況,若是沒有指定目錄,則對當前的目錄進行統計。正則表達式
面對對象時目錄文件,而不是其餘普通文件shell
NAME
du - estimate file space usage
SYNOPSIS
du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F
DESCRIPTION
Summarize disk usa-- 只顯示大小大於SIZE的目錄文件express
ge of each FILE, recursively for directories.
Mandatory arguments to long options are mandatory for short options too.app
(一)顯示單位選項:ui
-B, --block-size=SIZE scale sizes by SIZE before printing them. E.g., '-BM' prints sizes in units of 1,048,576 bytes. See SIZE format below.(總的用法)spa
-b, --bytes
equivalent to '--apparent-size --block-size=1'code
-k like --block-size=1K
-m like --block-size=1M
-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G) (來個自動選擇顯示單位,相似與free命令)
--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 likeorm
-c, --total produce a grand total -- 最後顯示總的空間大小
(此處牽扯到一個概念:實際文件大小與disk usage的差異)
對象
(二)範圍圈定選項(選出符合特定條件的文件):blog
I.深度:
-d, --max-depth=N -- 指定統計的文件的深度 (有點相似與find的一個參數)
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
II.大小
-t, --threshold=SIZE
exclude entries smaller than SIZE if positive, or entries
greater than SIZE if negative
1 +SIZE (K | M | G ...) 只顯示大小大於SIZE的目錄文件 2 -SIZE (K | M | G ... ) 只顯示大小小於SIZE的目錄文件
III.時間
--time show time of the last modification of any file in the direc‐
tory, or any of its subdirectories
--time=WORD
show time as WORD instead of modification time: atime, access,
use, ctime or status
--time-style=STYLE
show times using style STYLE: full-iso, long-iso, iso, +FORMAT
FORMAT is interpreted like 'date'
顯示時間一覽中,指定顯示的特定時間是 atime access use ctime or status
嚴格來講這個選項不是起到範圍排除的做用只是一個附加項
IV.exclude
-X, --exclude-from=FILE 這個沒看懂
exclude files that match any pattern in FILE
--exclude=PATTERN 任何符合PATTERN的目錄均不在顯示之列(能夠使用通配符來擴展)
exclude files that match PATTERN
-x, --one-file-system
skip directories on different file systems
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).
對於PATTERN能夠使用通配符進行匹配(不是正則表達式)這是個頗有用的選項。