du -- disk usage

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 like
orm

       -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能够使用通配符进行匹配(不是正则表达式)这是个颇有用的选项。