<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[刘新修]]></title> 
<link>http://liuxinxiu.com:80/index.php</link> 
<description><![CDATA[刘新修的个人博客 (Liuxinxiu'S Blog)]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[刘新修]]></copyright>
<item>
<link>http://liuxinxiu.com:80/s//</link>
<title><![CDATA[Linux shell判断文件和文件夹是否存在]]></title> 
<author>刘新修 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[Linux/Unix]]></category>
<pubDate>Fri, 24 Mar 2017 09:22:18 +0000</pubDate> 
<guid>http://liuxinxiu.com:80/s//</guid> 
<description>
<![CDATA[ 
	<p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">#!/bin/sh &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">myPath=&quot;/var/log/httpd/&quot; &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">myFile=&quot;/var /log/httpd/access.log&quot; &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">#这里的-x 参数判断$myPath是否存在并且是否具有可执行权限 &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">if [ ! -x &quot;$myPath&quot;]; then &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">　　mkdir &quot;$myPath&quot; &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">fi &nbsp;</span></font><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;"><br /></span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">#这里的-d 参数判断$myPath是否存在 &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">if [ ! -d &quot;$myPath&quot;]; then &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">　　mkdir &quot;$myPath&quot; &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">fi &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">#这里的-f参数判断$myFile是否存在 &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">if [ ! -f &quot;$myFile&quot; ]; then &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">　　touch &quot;$myFile&quot; &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">fi &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">#其他参数还有-n,-n是判断一个变量是否是否有值 &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">if [ ! -n &quot;$myVar&quot; ]; then &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">　　echo &quot;$myVar is empty&quot; &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">　　exit 0 &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">fi &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">#两个变量判断是否相等 &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">if [ &quot;$var1&quot; = &quot;$var2&quot; ]; then &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">　　echo '$var1 eq $var2' &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">else &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">　　echo '$var1 not eq $var2' &nbsp;</span></font></p><p><font face="Courier New"><span style="font-size: 12px; white-space: pre-wrap;">fi</span></font></p>
]]>
</description>
</item><item>
<link>http://liuxinxiu.com:80/s//#blogcomment</link>
<title><![CDATA[[评论] Linux shell判断文件和文件夹是否存在]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://liuxinxiu.com:80/s//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>