<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[[实践OK]Linux 下的du命令结合awk通过du来扫描大于G的文件夹,新加所有文件上G的查找方法-from:scottjiang江庆海,外加上文件层级大小统计。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Unix/LinuxC技术]]></category>
<pubDate>Thu, 12 May 2011 04:48:06 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	一、查找上G的文件：<br/><textarea name="code" class="C" rows="15" cols="100">
find . -type f &#124;xargs -i du -lh &#123;&#125; &#124;awk &#039;&#123;if(match($1, &quot;G&quot;)&gt;0) print $0&#125;&#039;
</textarea><br/>列出上G并删除的命令，如果加上 &#124;sh 就能删除掉：<br/>find /data/logs/nginx -type f -name &quot;*.log-*&quot; &#124;xargs -i du -lh &#123;&#125; &#124;awk &#039;&#123;if(match($1, &quot;G&quot;)&gt;0) print $0&#125;&#039; &#124;awk &#039;&#123;print &quot;rm -Rf &quot; $2&#125;&#039;<br/><br/>du -sh /data/logs/swoole/swoole.log<br/>99G&nbsp;&nbsp;&nbsp;&nbsp; /data/logs/swoole/swoole.log<br/>上G的日志/data/logs/swoole/swoole.log清空即可：<br/> find /data/logs/swoole -type f -name &quot;*.log&quot; &#124;xargs -i du -lh &#123;&#125; &#124;awk &#039;&#123;if(match($1, &quot;G&quot;)&gt;0) print $0&#125;&#039; &#124;awk &#039;&#123;print &quot;echo &gt; &quot; $2&#125;&#039;&#124;sh<br/><textarea name="code" class="php" rows="15" cols="100">
find /data/logs/swoole -type f -name &quot;*.log&quot; &#124;xargs -i du -lh &#123;&#125; &#124;awk &#039;&#123;if(match($1, &quot;G&quot;)&gt;0) print $0&#125;&#039; &#124;awk &#039;&#123;print &quot;echo &gt; &quot; $2&#125;&#039;
echo &gt; /data/logs/swoole/swoole.log

find /data/logs/swoole -type f -name &quot;*.log&quot; &#124;xargs -i du -lh &#123;&#125; &#124;awk &#039;&#123;if(match($1, &quot;G&quot;)&gt;0) print $0&#125;&#039; &#124;awk &#039;&#123;print &quot;echo &gt; &quot; $2&#125;&#039;
du -sh /data/logs/swoole/swoole.log&nbsp;&nbsp; 512K&nbsp;&nbsp;&nbsp;&nbsp;/data/logs/swoole/swoole.log
</textarea><br/><br/>#定时清空swoole测试机上上G的文件<br/>* 1 * * *&nbsp;&nbsp;find /data/logs/swoole -type f -name &quot;*.log&quot; &#124;xargs -i du -lh &#123;&#125; &#124;awk &#039;&#123;if(match($1, &quot;G&quot;)&gt;0) print $0&#125;&#039; &#124;awk &#039;&#123;print &quot;echo &gt; &quot; $2&#125;&#039;&#124;sh<br/><br/>二、查找上的G目录：<br/><textarea name="code" class="php" rows="15" cols="100">
du -lh&#124;awk &#039;&#123;if(match($1, &quot;G&quot;)&gt;0) print $0&#125;&#039;
</textarea><br/><br/>这样来查找：<br/><textarea name="code" class="php" rows="15" cols="100">
find . -name &quot;*&quot; &#124;du -sh *&#124;awk &#039;&#123;if(match($1, &quot;G&quot;)&gt;0) print $0 &#125;&#039;
</textarea><br/><br/>示例Demo：<br/>root@116.255.139.240:/data1/logs#&nbsp;&nbsp;&nbsp;&nbsp; find . -name &quot;*&quot; &#124;du -sh *&#124;awk &#039;&#123;if(match($1, &quot;G&quot;)&gt;0) print $0 &#125;&#039;<br/>5.0G&nbsp;&nbsp;&nbsp;&nbsp;access.log<br/><br/><br/><br/>Linux中清理磁盘空间时，经常需要找出大于200M的文件。<br/>这个命令可以实现这个功能：<br/>find / -size +200M -exec du -h &#123;&#125; &#92;;<br/><br/><br/>http://blog.csdn.net/yfleng2002/article/details/8080556<br/><br/><br/>三、文件夹大小的及层级统计：<br/>du -h --max-depth=1 &#124;grep &#039;G&#039; &#124;sort&nbsp;&nbsp; #查看上G目录并排序<br/>du -h --max-depth=0 user<br/>--max-depth＝n表示仅仅深入到第n层文件夹，此处设置为0，即表示不深入到子文件夹。<br/><br/>du -h --max-depth=1 /home/&#124;grep [M] &#124;sort&nbsp;&nbsp;&nbsp;&nbsp; #查看上M目录并排序<br/>21M&nbsp;&nbsp;&nbsp;&nbsp; /home/jackx<br/>32M&nbsp;&nbsp;&nbsp;&nbsp; /home/<br/>9.2M&nbsp;&nbsp;&nbsp;&nbsp;/home/jackxiang<br/><br/>du -h --max-depth=1 &#124;sort&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#查看当前目录下所有一级子目录文件夹大小 并排序<br/>1.2G&nbsp;&nbsp;&nbsp;&nbsp;.<br/>12K&nbsp;&nbsp;&nbsp;&nbsp; ./.ssh<br/>16K&nbsp;&nbsp;&nbsp;&nbsp; ./.gconfd<br/>16K&nbsp;&nbsp;&nbsp;&nbsp; ./js<br/>45M&nbsp;&nbsp;&nbsp;&nbsp; ./yucc<br/>464K&nbsp;&nbsp;&nbsp;&nbsp;./s<br/>48K&nbsp;&nbsp;&nbsp;&nbsp; ./.gconf<br/>48K&nbsp;&nbsp;&nbsp;&nbsp; ./.subversion<br/><br/>参考：http://www.cnblogs.com/mfryf/p/3243211.html<br/><br/><br/>awk match用法,上面是返回值作上G判断，还能正则，如下：<br/>cat test <br/>this is wang ,not wan<br/><br/>that is chen, not che <br/><br/>this is chen ,and wang ,not wan che <br/>awk &#039;&#123;match($0,/.+is([^,]+).+not(.+)/,a);print a[1],a[2]&#125;&#039; test<br/> wang&nbsp;&nbsp; wan<br/> <br/> chen&nbsp;&nbsp;che <br/> <br/> chen&nbsp;&nbsp; wan che <br/><br/>来自：https://www.cnblogs.com/timeisbiggestboss/p/7242351.html<br/>Tags - <a href="http://www.jackxiang.com/tags/2g/" rel="tag">2g</a> , <a href="http://www.jackxiang.com/tags/awk/" rel="tag">awk</a>
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [实践OK]Linux 下的du命令结合awk通过du来扫描大于G的文件夹,新加所有文件上G的查找方法-from:scottjiang江庆海,外加上文件层级大小统计。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>