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

25 lines
2.7 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="rmdir">rmdir</h1>
<p>用来删除空目录</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>rmdir命令</strong> 用来删除空目录。当目录不再被使用时或者磁盘空间已到达使用限定值就需要删除失去使用价值的目录。利用rmdir命令可以从一个目录中删除一个或多个空的子目录。该命令从一个目录中删除一个或多个子目录其中dirname佬表示目录名。如果dirname中没有指定路径则删除当前目录下由dirname指定的目录如dirname中包含路径则删除指定位置的目录。删除目录时必须具有对其父目录的写权限。</p>
<p>注意子目录被删除之前应该是空目录。就是说该目录中的所有文件必须用rm命令全部另外当前工作目录必须在被删除目录之上不能是被删除目录本身也不能是被删除目录的子目录。</p>
<p>虽然还可以用带有<code>-r</code>选项的rm命令递归删除一个目录中的所有文件和该目录本身但是这样做存在很大的危险性。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">rmdir(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-p或--parents删除指定目录后若该目录的上层目录已变成空目录则将其一并删除
--ignore-fail-on-non-empty此选项使rmdir命令忽略由于删除非空目录时导致的错误信息
-v或-verboes显示命令的详细执行过程
--help显示命令的帮助信息
--version显示命令的版本信息。</code></pre>
<h3 id="参数">参数</h3>
<p>目录列表:要删除的空目录列表。当删除多个空目录时,目录名之间使用空格隔开。</p>
<h3 id="实例">实例</h3>
<p>将工作目录下,名为 <code>www</code> 的子目录删除 :</p>
<div class="sourceCode" id="cb3"><pre><code class="language-bash"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="fu">rmdir</span> www</a></code></pre></div>
<p>在工作目录下的 www 目录中,删除名为 Test 的子目录。若 Test 删除后www 目录成为空目录,则 www 亦予删除。</p>
<div class="sourceCode" id="cb4"><pre><code class="language-bash"><a class="sourceLine" id="cb4-1" data-line-number="1"><span class="fu">rmdir</span> -p www/Test</a></code></pre></div>
<p>下面命令等价于 <code>rmdir a/b/c</code>, <code>rmdir a/b</code>, <code>rmdir a</code></p>
<div class="sourceCode" id="cb5"><pre><code class="language-bash"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="fu">rmdir</span> -p a/b/c</a></code></pre></div>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->