2019-04-21 11:50:48 +08:00

50 lines
1.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="type">type</h1>
<p>显示指定命令的类型</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>type命令</strong> 用来显示指定命令的类型,判断给出的指令是内部指令还是外部指令。</p>
<p>命令类型:</p>
<ul>
<li>alias别名。</li>
<li>keyword关键字Shell保留字。</li>
<li>function函数Shell函数。</li>
<li>builtin内建命令Shell内建命令。</li>
<li>file文件磁盘文件外部命令。</li>
<li>unfound没有找到。</li>
</ul>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">type(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-t输出“file”、“alias”或者“builtin”分别表示给定的指令为“外部指令”、“命令别名”或者“内部指令”
-p如果给出的指令为外部指令则显示其绝对路径
-a在环境变量“PATH”指定的路径中显示给定指令的信息包括命令别名。</code></pre>
<h3 id="参数">参数</h3>
<p>指令:要显示类型的指令。</p>
<h3 id="实例">实例</h3>
<pre><code class="language-bash">[root@localhost ~]# type ls
ls is aliased to `ls --color=tty&#39;
[root@localhost ~]# type cd
cd is a shell builtin
[root@localhost ~]# type date
date is /bin/date
[root@localhost ~]# type mysql
mysql is /usr/bin/mysql
[root@localhost ~]# type nginx
-bash: type: nginx: not found
[root@localhost ~]# type if
if is a shell keyword
[root@localhost ~]# type which
which is aliased to `alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde&#39;
[root@localhost ~]# type -a cd
cd is a shell builtin
[root@localhost ~]# type -a grep
grep is /bin/grep</code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->