页面“每天一命令之du”与“每天一命令之grep”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
docker>Evan
 
docker>Evan
 
第1行: 第1行:
  
== du正文==
+
=常用参数=
 
<pre>
 
<pre>
0. name
+
#多个and
NAME
+
ps -ef | grep -E 'tomcat1 |tomcat2 |grep -v grep '
      du - estimate file space usage
 
 
 
1.命令格式:
 
  du [选项][文件]
 
 
 
SYNOPSIS
 
      du [OPTION]... [FILE]...
 
      du [OPTION]... --files0-from=F
 
 
 
2. 命令功能
 
DESCRIPTION
 
      显示每个文件和目录的磁盘使用空间
 
      Summarize disk usage of the set of FILEs, recursively for directories.
 
 
 
      Mandatory arguments to long options are mandatory for short options too.
 
 
 
3. 命令参数
 
-a或-all  显示目录中个别文件的大小。  
 
-s或--summarize  仅显示总计,只列出最后加总的值。
 
-h或--human-readable  以K,M,G为单位,提高信息的可读性。
 
 
 
--exclude=PATTERN 非常好用的参数 排除 取反 ,记得不是一个路径,而是要用相对路径
 
du -sh /*  --exclude=data --exclude=data1 --exclude=data2 --exclude=data3 --exclude=proc
 
 
 
常用就是 du -sh
 
 
</pre>
 
</pre>
  
==du -sh 排序==
+
[http://blog.51cto.com/haowen/2068456 find & grep 总结]
<pre>
 
1. sort --help 可是有
 
-h, --human-numeric-sort 使用易读性数字(例如: 2K 1G) 参数的排序不好,
 
du -h | sort -h
 
  
2.du -s * | sort -k 1 -g | awk '{print $2}' | xargs du -sh {}
+
== 精准 非贪婪匹配==
 
+
<pre> -w, --word-regexp        强制 PATTERN 仅完全匹配字词
3.  
+
              Select  only  those  lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a
du -sk * | sort -n | #以 K 字节的方式排序
+
              non-word constituent character.  Similarly, it must be either at the end of the line or followed by a non-word  constituent  character.  Word-constituent  characters  are
 
+
              letters, digits, and the underscore. This option has no effect if -x is also specified.
4.good
 
du -s * | sort -nr|head  #我一般用这个排序
 
 
</pre>
 
</pre>
 
+
  [[category:shell]]
==在du命令里如何排除其它目录==
 
<pre>
 
--exclude=PATTERN 不是一个路径
 
 
 
du -sh /* --exclude=data --exclude=data1  --exclude=proc
 
</pre>
 
 
 
==参考==
 
 
 
 
 
[http://www.cnblogs.com/peida/archive/2012/12/10/2810755.html 每天一个linux命令(34):du 命令]
 
 
 
 
 
[http://blog.sina.com.cn/s/blog_48e13c9e0102vezm.html Linux按文件夹大小排序命令 du -k | sort -rn ]
 
 
 
[http://dengxi.blog.51cto.com/4804263/1701438 du和sort 命令的使用和技巧]
 
 
 
Linux du命令查看文件夹大小并按降序排列
 
http://m.jb51.net/article/74737.htm
 
 
 
将du的输出按文件大小排序
 
https://blog.lilydjwg.me/posts/18368.html
 
[[category:ops]] [[category:shell]][[category:linux]]
 

2018年12月27日 (四) 08:18的版本

常用参数

#多个and 
ps -ef | grep  -E 'tomcat1 |tomcat2 |grep -v grep '

find & grep 总结

精准 非贪婪匹配

 -w, --word-regexp         强制 PATTERN 仅完全匹配字词
              Select  only  those  lines containing matches that form whole words.  The test is that the matching substring must either be at the beginning of the line, or preceded by a
              non-word constituent character.  Similarly, it must be either at the end of the line or followed by a non-word  constituent  character.   Word-constituent  characters  are
              letters, digits, and the underscore.  This option has no effect if -x is also specified.