mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-10-11 08:53:20 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
<h2 id="补充说明">补充说明</h2>
|
||||
<p><strong>test命令</strong> 是shell环境中测试条件表达式的实用工具。</p>
|
||||
<h3 id="语法">语法</h3>
|
||||
<pre><code>test(选项)</code></pre>
|
||||
<pre><code class="language-bash">test(选项)</code></pre>
|
||||
<h3 id="选项">选项</h3>
|
||||
<pre><code>-b<文件>:如果文件为一个块特殊文件,则为真;
|
||||
<pre><code class="language-bash">-b<文件>:如果文件为一个块特殊文件,则为真;
|
||||
-c<文件>:如果文件为一个字符特殊文件,则为真;
|
||||
-d<文件>:如果文件为一个目录,则为真;
|
||||
-e<文件>:如果文件存在,则为真;
|
||||
@@ -24,25 +24,25 @@
|
||||
<h3 id="实例">实例</h3>
|
||||
<p>linux中shell编程中的test常见用法:</p>
|
||||
<p><strong>判断表达式</strong></p>
|
||||
<pre><code>if test #表达式为真
|
||||
<pre><code class="language-bash">if test #表达式为真
|
||||
if test ! #表达式为假
|
||||
test 表达式1 –a 表达式2 #两个表达式都为真
|
||||
test 表达式1 –o 表达式2 #两个表达式有一个为真
|
||||
test 表达式1 ! 表达式2 #条件求反</code></pre>
|
||||
<p><strong>判断字符串</strong></p>
|
||||
<pre><code>test –n 字符串 #字符串的长度非零
|
||||
<pre><code class="language-bash">test –n 字符串 #字符串的长度非零
|
||||
test –z 字符串 #字符串的长度是否为零
|
||||
test 字符串1=字符串2 #字符串是否相等,若相等返回true
|
||||
test 字符串1!=字符串2 #字符串是否不等,若不等反悔false</code></pre>
|
||||
<p><strong>判断整数</strong></p>
|
||||
<pre><code>test 整数1 -eq 整数2 #整数相等
|
||||
<pre><code class="language-bash">test 整数1 -eq 整数2 #整数相等
|
||||
test 整数1 -ge 整数2 #整数1大于等于整数2
|
||||
test 整数1 -gt 整数2 #整数1大于整数2
|
||||
test 整数1 -le 整数2 #整数1小于等于整数2
|
||||
test 整数1 -lt 整数2 #整数1小于整数2
|
||||
test 整数1 -ne 整数2 #整数1不等于整数2</code></pre>
|
||||
<p><strong>判断文件</strong></p>
|
||||
<pre><code>test File1 –ef File2 两个文件是否为同一个文件,可用于硬连接。主要判断两个文件是否指向同一个inode。
|
||||
<pre><code class="language-bash">test File1 –ef File2 两个文件是否为同一个文件,可用于硬连接。主要判断两个文件是否指向同一个inode。
|
||||
test File1 –nt File2 判断文件1是否比文件2新
|
||||
test File1 –ot File2 判断文件1比是否文件2旧
|
||||
test –b file #文件是否块设备文件
|
||||
|
Reference in New Issue
Block a user