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

22 lines
1.6 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="exec">exec</h1>
<p>调用并执行指定的命令</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>exec命令</strong> 用于调用并执行指令的命令。exec命令通常用在shell脚本程序中可以调用其他的命令。如果在当前终端中使用命令则当指定的命令执行完毕后会立即退出终端。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">exec(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-c在空环境中执行指定的命令。</code></pre>
<h3 id="参数">参数</h3>
<p>指令:要执行的指令和相应的参数。</p>
<h3 id="实例">实例</h3>
<p>首先使用echo命令将文本“Linux C++”进行输出,输入如下命令:</p>
<pre><code class="language-bash">echo Linux C++ #输出指定信息</code></pre>
<p>执行上面的指令后,输出如下信息:</p>
<pre><code class="language-bash">Linux C++ #输出信息</code></pre>
<p>然后再使用exec命令调用echo命令输出同样的信息并且对输出的信息进行对比输入指令如下所示</p>
<pre><code class="language-bash">exec -c echo Linux C++ #调用命令</code></pre>
<p>执行以上命令后,其输出信息如下:</p>
<pre><code class="language-bash">Linux C++ #使用指定指令输出信息</code></pre>
<p>通过比较两者执行后的结果来看所实现的功能是相同的即使用exec命令调用echo命令成功。</p>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->