<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[刘佳的技术日志、博客]]></title> 
<link>http://www.52zhe.cn/index.php</link> 
<description><![CDATA[技术的事，喜欢就研究。]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[刘佳的技术日志、博客]]></copyright>
<item>
<link>http://www.52zhe.cn/read.php/.htm</link>
<title><![CDATA[shell中的判断符，转自鸟哥。]]></title> 
<author>kook &lt;admin@yourname.com&gt;</author>
<category><![CDATA[SHELL]]></category>
<pubDate>Fri, 13 Jul 2007 06:19:22 +0000</pubDate> 
<guid>http://www.52zhe.cn/read.php/.htm</guid> 
<description>
<![CDATA[ 
	转自<a href="http://linux.vbird.org" target="_blank">鸟哥</a><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/><span style="color: #0000FF;">1. 关于某个档名的『类型』侦测(存在与否)，如 test -e filename</span><br/>-e &nbsp;该『档名』是否存在？(常用)<br/>-f &nbsp;该『档名』是否为档案(file)？(常用)<br/>-d &nbsp;该『文件名』是否为目录(directory)？(常用)<br/>-b &nbsp;该『文件名』是否为一个 block device 装置？<br/>-c &nbsp;该『文件名』是否为一个 character device 装置？<br/>-S &nbsp;该『档名』是否为一个 Socket 档案？<br/>-p &nbsp;该『档名』是否为一个 FIFO (pipe) 档案？<br/>-L &nbsp;该『档名』是否为一个连结档？<br/><br/><span style="color: #0000FF;">2. 关于档案的权限侦测，如 test -r filename</span><br/>-r &nbsp;侦测该文件名是否具有『可读』的属性？<br/>-w &nbsp;侦测该档名是否具有『可写』的属性？<br/>-x &nbsp;侦测该档名是否具有『可执行』的属性？<br/>-u &nbsp;侦测该文件名是否具有『SUID』的属性？<br/>-g &nbsp;侦测该文件名是否具有『SGID』的属性？<br/>-k &nbsp;侦测该文件名是否具有『Sticky bit』的属性？<br/>-s &nbsp;侦测该档名是否为『非空白档案』？<br/><br/><span style="color: #0000FF;">3. 两个档案之间的比较，如： test file1 -nt file2</span><br/>-nt &nbsp;(newer than)判断 file1 是否比 file2 新<br/>-ot &nbsp;(older than)判断 file1 是否比 file2 旧<br/>-ef &nbsp;判断 file2 与 file2 是否为同一档案，可用在判断 hard link 的判定上。 主要意义在判定，两个档案是否均指向同一个 inode 哩！<br/><br/><span style="color: #0000FF;">4. 关于两个整数之间的判定，例如 test n1 -eq n2</span><br/>-eq &nbsp;两数值相等 (equal)<br/>-ne &nbsp;两数值不等 (not equal)<br/>-gt &nbsp;n1 大于 n2 (greater than)<br/>-lt &nbsp;n1 小于 n2 (less than)<br/>-ge &nbsp;n1 大于等于 n2 (greater than or equal)<br/>-le &nbsp;n1 小于等于 n2 (less than or equal)<br/><br/><span style="color: #0000FF;">5. 判定字符串的数据</span><br/>test -z string &nbsp;判定字符串是否为 0 ？若 string 为空字符串，则为 true<br/>test -n string &nbsp;判定字符串是否非为 0 ？若 string 为空字符串，则为 false。<br/>注： -n 亦可省略<br/>test str1 = str2 &nbsp;判定 str1 是否等于 str2 ，若相等，则回传 true<br/>test str1 != str2 &nbsp;判定 str1 是否不等于 str2 ，若相等，则回传 false<br/><br/><span style="color: #0000FF;">6. 多重条件判定，例如： test -r filename -a -x filename</span><br/>-a &nbsp;(and)两状况同时成立！例如 test -r file -a -x file，则 file 同时具有 r 与 x 权限时，才回传 true。<br/>-o &nbsp;(or)两状况任何一个成立！例如 test -r file -o -x file，则 file 具有 r 或 x 权限时，就可回传 true。<br/>! &nbsp;反相状态，如 test ! -x file ，当 file 不具有 x 时，回传 true<br/></div></div><br/>
]]>
</description>
</item><item>
<link>http://www.52zhe.cn/read.php?&amp;guid=0#topreply</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.52zhe.cn/read.php?&amp;guid=0#topreply</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>