台州网站建设方案网络推广方法有哪几种
文章目录
- 官方介绍
- 简单介绍
- 常用选项
- 与单位相关的选项
- --apparent-size
- -B, --block-size=SIZE
- -b, --bytes
- -k
- -m
- 与遍历深度相关的选项
- -s, --summarize
- -d, --max-depth=N
- -h, --human-readable
- 常用案例介绍
- 1.直观地显示当前目录文件大小:`du -sh`
- 2.直观地显示当前目录文件内所有文件大小,不递归:`du -h --max-depth=1`
- 3.指定文件/文件夹`du file`
- 4.显示文件夹内所有文件大小`du -a`
- 5.排除某文件`du --exclude=""`
官方介绍
我的理解:du是document的简写形式。
Ubuntu的du命名解释详情:man du
输出内容:
DU(1) User Commands DU(1)NAMEdu - estimate file space usageSYNOPSISdu [OPTION]... [FILE]...du [OPTION]... --files0-from=FDESCRIPTIONSummarize disk usage of the set of FILEs, recursively for directories.Mandatory arguments to long options are mandatory for short options too.-0, --nullend each output line with NUL, not newline-a, --allwrite counts for all files, not just directories--apparent-sizeprint apparent sizes, rather than disk usage; although the apparent size isusually smaller, it may be larger due to holes in ('sparse') files, internalfragmentation, indirect blocks, and the like-B, --block-size=SIZEscale sizes by SIZE before printing them; e.g., '-BM' prints sizes in unitsof 1,048,576 bytes; see SIZE format below-b, --bytesequivalent to '--apparent-size --block-size=1'-c, --totalproduce a grand total-D, --dereference-argsdereference only symlinks that are listed on the command line-d, --max-depth=Nprint the total for a directory (or file, with --all) only if it is N orfewer levels below the command line argument; --max-depth=0 is the same as--summarize--files0-from=Fsummarize disk usage of the NUL-terminated file names specified in file F;if F is -, then read names from standard input-H equivalent to --dereference-args (-D)-h, --human-readableprint sizes in human readable format (e.g., 1K 234M 2G)--inodeslist inode usage information instead of block usage-k like --block-size=1K-L, --dereferencedereference all symbolic links-l, --count-linkscount sizes many times if hard linked-m like --block-size=1M-P, --no-dereferencedon't follow any symbolic links (this is the default)-S, --separate-dirsfor directories do not include size of subdirectories--si like -h, but use powers of 1000 not 1024-s, --summarizedisplay only a total for each argument-t, --threshold=SIZEexclude entries smaller than SIZE if positive, or entries greater than SIZEif negative--time show time of the last modification of any file in the directory, or any ofits subdirectories--time=WORDshow time as WORD instead of modification time: atime, access, use, ctime orstatus--time-style=STYLEshow times using STYLE, which can be: full-iso, long-iso, iso, or +FORMAT;FORMAT is interpreted like in 'date'-X, --exclude-from=FILEexclude files that match any pattern in FILE--exclude=PATTERNexclude files that match PATTERN-x, --one-file-systemskip directories on different file systems--help display this help and exit--versionoutput version information and exitDisplay values are in units of the first available SIZE from --block-size, and theDU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. Otherwise, unitsdefault to 1024 bytes (or 512 if POSIXLY_CORRECT is set).The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Unitsare K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).PATTERNSPATTERN is a shell pattern (not a regular expression). The pattern ? matches anyone character, whereas * matches any string (composed of zero, one or multiplecharacters). For example, *.o will match any files whose names end in .o. There‐fore, the commanddu --exclude='*.o'will skip all files and subdirectories ending in .o (including the file .o itself).AUTHORWritten by Torbjorn Granlund, David MacKenzie, Paul Eggert, and Jim Meyering.REPORTING BUGSGNU coreutils online help: <http://www.gnu.org/software/coreutils/>Report du translation bugs to <http://translationproject.org/team/>COPYRIGHTCopyright © 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3or later <http://gnu.org/licenses/gpl.html>.This is free software: you are free to change and redistribute it. There is NOWARRANTY, to the extent permitted by law.SEE ALSOFull documentation at: <http://www.gnu.org/software/coreutils/du>or available locally via: info '(coreutils) du invocation'GNU coreutils 8.28 January 2018 DU(1)
简单介绍
du - estimate file space usage
:估计文件空间使用情况。
Summarize disk usage of the set of FILEs, recursively for directories.
:递归遍历目录。
默认设置(不指定文件夹、不带选项的情况下):
- 默认情况下遍历当前目录下的所有文件和目录、以及子目录。相当于加了
-a
。 - 容量表示磁盘使用量;单位为kb,相当于加了
--block-size=1k
。 - 最后面会显示当前文件夹的总的大小。
举例:
$ du
……
40 ./03H5游戏/八款经典HTML5小游戏源码/08/js
20 ./03H5游戏/八款经典HTML5小游戏源码/08/src/views
89 ./03H5游戏/八款经典HTML5小游戏源码/08/src
4795 ./03H5游戏/八款经典HTML5小游戏源码/08
18476 ./03H5游戏/八款经典HTML5小游戏源码
19308 ./03H5游戏
82260 .
常用选项
与单位相关的选项
–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
显示文件的表面的大小,而不是默认的磁盘使用量(–block-size=1k)。一般情况下都会比磁盘使用量少,如果你有注意的话window的容量也是有两种显示的。
$ du --max-depth=1 --apparent-size
19 ./.git
15163 ./00实用模板
13076 ./00登录模板
8666 ./01H5
2004 ./01H5-CSS3
9371 ./01H5-CSS3-3D
621 ./01H5-SVG
11226 ./02H5-Canvas
18598 ./03H5游戏
78742 .$ du --max-depth=1
48 ./.git
15970 ./00实用模板
13831 ./00登录模板
9069 ./01H5
2190 ./01H5-CSS3
9535 ./01H5-CSS3-3D
675 ./01H5-SVG
11623 ./02H5-Canvas
19308 ./03H5游戏
82260 .
-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
The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units
are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,… (powers of 1000).
注:这里不区分大小写,如:K和k是一样的。
以什么单位显示块的大小。-B
需要结合下面的选项一起使用。如:
$ du -BK --max-depth=1
48K ./.git
15970K ./00实用模板
13831K ./00登录模板
9069K ./01H5
2190K ./01H5-CSS3
9535K ./01H5-CSS3-3D
675K ./01H5-SVG
11623K ./02H5-Canvas
19308K ./03H5游戏
82260K .$ du -BM --max-depth=1
1M ./.git
16M ./00实用模板
14M ./00登录模板
9M ./01H5
3M ./01H5-CSS3
10M ./01H5-CSS3-3D
1M ./01H5-SVG
12M ./02H5-Canvas
19M ./03H5游戏
81M .
长命令格式(和下面的效果一样):
$ du --max-depth=1 --block-size=1k
48 ./.git
15970 ./00实用模板
13831 ./00登录模板
9069 ./01H5
2190 ./01H5-CSS3
9535 ./01H5-CSS3-3D
675 ./01H5-SVG
11623 ./02H5-Canvas
19308 ./03H5游戏
82260 .$ du --max-depth=1 --block-size=1m
1 ./.git
16 ./00实用模板
14 ./00登录模板
9 ./01H5
3 ./01H5-CSS3
10 ./01H5-CSS3-3D
1 ./01H5-SVG
12 ./02H5-Canvas
19 ./03H5游戏
81 .
-b, --bytes
equivalent to ‘–apparent-size --block-size=1’
(文件的表面大小)单位为字节。
-k
like --block-size=1K
单位为kb。
-m
like --block-size=1M
单位为mb。
与遍历深度相关的选项
-s, --summarize
display only a total for each argument
只显示当前目录的总的大小。
$ du --summarize
82260 .
-d, --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
指定遍历深度,如果不指定表示遍历到底;如果是0,同--summarize
只显示总大小;如果是1,表示只遍历当前目录,不递归遍历子目录(如果有的话)。
$ du --max-depth=0
82260 .$ du --max-depth=1
48 ./.git
15970 ./00实用模板
13831 ./00登录模板
9069 ./01H5
2190 ./01H5-CSS3
9535 ./01H5-CSS3-3D
675 ./01H5-SVG
11623 ./02H5-Canvas
19308 ./03H5游戏
82260 .
-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
形象的显示单位,使其更加易读。
$ du -h --max-depth=1
48K ./.git
16M ./00实用模板
14M ./00登录模板
8.9M ./01H5
2.2M ./01H5-CSS3
9.4M ./01H5-CSS3-3D
675K ./01H5-SVG
12M ./02H5-Canvas
19M ./03H5游戏
81M .
常用案例介绍
1.直观地显示当前目录文件大小:du -sh
$ du -sh
81M .
2.直观地显示当前目录文件内所有文件大小,不递归:du -h --max-depth=1
$ du -h --max-depth=1
48K ./.git
16M ./00实用模板
14M ./00登录模板
8.9M ./01H5
2.2M ./01H5-CSS3
9.4M ./01H5-CSS3-3D
675K ./01H5-SVG
12M ./02H5-Canvas
19M ./03H5游戏
81M .
3.指定文件/文件夹du file
$ ls
00登录模板/ 01H5/ 01H5-CSS3-3D/ 02H5-Canvas/ LICENSE.txt
00实用模板/ 01H5-CSS3/ 01H5-SVG/ 03H5游戏/ README.md# 指定文件
$ du LICENSE.txt
4 LICENSE.txt# 指定文件夹
du 01H5/
……
260 01H5/html5音乐播放器音频播放代码/img
96 01H5/html5音乐播放器音频播放代码/js
196 01H5/html5音乐播放器音频播放代码/mp3
609 01H5/html5音乐播放器音频播放代码
1 01H5/火花文字动画html5_css3_wenzdh/css
12 01H5/火花文字动画html5_css3_wenzdh/js
18 01H5/火花文字动画html5_css3_wenzdh
9069 01H5/
4.显示文件夹内所有文件大小du -a
如果不加-a
,默认情况下只显示文件夹大小,不显示文件大小。
# -a, --all write counts for all files, not just directories
# 显示所有文件的大小,而不仅仅是文件夹
$ du -ah
1.4M ./1.5.0-阿里巴巴Java开发手册(华山版).pdf
76K ./CollectHomework/CollectHomework-1.jpg
128K ./CollectHomework/CollectHomework-2.jpg
204K ./CollectHomework
56K ./hello-word/github-bootstrap语言识别情况.jpg
20K ./hello-word/github-hello-world1语言识别情况.jpg
28K ./hello-word/github-hello-world2语言识别情况.jpg
12K ./hello-word/github-hello-world语言识别情况.jpg
64K ./hello-word/github语言识别情况.jpg
52K ./hello-word/hello-world-github.png
16K ./hello-word/hello-world-github1.png
252K ./hello-word
1.9M
5.排除某文件du --exclude=""
如果不加路径参数,默认是查询当前文件夹的文件大小。
你也可以指定具体的文件(夹),就像这样:du -sh ./test/
,查看test文件夹大小。
当然你也可以排除具体的文件(夹),就像这样:du -sh --exclude="./test/"
,当前目录的排除test文件夹后的其余文件的大小。
这篇文章也分享了一些案例:https://blog.csdn.net/learner198461/article/details/54602324