<?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[请问如何用Shell编: 在当前目录下保留指定日期的文件,其余的全部删除?]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Tue, 17 Sep 2013 05:09:47 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	<br/>作者：作者<br/>来自：无名<br/><br/>#!/bin/sh<br/>ls -1 &#124;while read line<br/>do<br/>month=`echo $line&#124;awk &#039;&#123;print $6&#125;&#039;`<br/>day=`echo $line&#124;awk &#039;&#123;print $7&#125;&#039;<br/>time=echo $line&#124;awk &#039;&#123;print $8&#125;&#039;<br/>file=`echo $linr&#124;awk &#039;&#123;print $9&#125;&#039;<br/>if [ $month=&quot;RIGHTMONTH&quot; -a $day=&quot;RIGHTDAY&quot; -a $time=&quot;RIGHTTIME&quot;<br/>then<br/>continue<br/>else<br/>rm $filr<br/>fi<br/>done<br/><br/>RIGHTMON RIGHTDAY RIGHTTIME为你制定的时间.<br/>rm<br/><br/><br/>多谢!<br/>但有个问题:<br/>if [ $month=&quot;Jul&quot; -a $day=&quot;29&quot;]<br/>.....<br/>好像不太对,运行完了好像没有正确判断,什么文件也没删除!<br/><br/><br/>如果echo $LANG = zh<br/>则$month是中文.<br/><br/>不是,是英文,我用ksh -x 来执行,发现一行如: [May=Jul -a 9=29] 它还是继续执行continue的内容,不是执行else<br/><br/>if [ $month=&quot;Jul&quot; -a $day=&quot;29&quot;]改为<br/>if [ $month=&quot;Jul&quot; -a $day=&quot;29&quot; ]试试看<br/><br/>成功!<br/>if [ &quot;$month&quot; = &quot;Jul&quot; -a &quot;$day = &quot;29&quot; ]<br/><br/><br/>对，shell编程中的() ,[] , &#123;&#125; 前后最好都要空格。<br/>来自：http://www.phpchina.com/download/handbook/linux-html/406.html<br/><br/>参考<br/>http://www.phpchina.com/download/handbook/linux-html/406.html<br/>Khairi Wang- SNG(66237759)&nbsp;&nbsp;下午 12:54:37<br/>ll &#124; awk &#039;&#123;if($6~/01$/)&#123;print $8&#125;&#125;&#039; &#124; xargs rm<br/>如果文件不是很多 这个命令可以<br/>$6 文件日期<br/>$8 文件名<br/>Jack-回忆未来(372647693)&nbsp;&nbsp;下午 12:55:26<br/> 好像文件多了，要用另外一个命令，我有次写crontab就遇到文件多用rm好像不行。<br/>Khairi Wang- SNG(66237759)&nbsp;&nbsp;下午 12:56:22<br/>文件多了 得用find -exec
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] 请问如何用Shell编: 在当前目录下保留指定日期的文件,其余的全部删除?]]></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>