<p>由于复制或移动的问题不清楚,有两种方法,<strong>不复制!即使是第二部分也不能有效地复制数据!你知道吗</p>
<h3>简单的<a href="/questions/tagged/bash" class="post-tag" title="show questions tagged 'bash'" rel="tag">bash</a>命令</h3>
<p>简单地说:</p>
<pre><code>cd foo/bar/baz
mv -it alpha/beta/gamma/files alpha_*/beta/gamma/files/uniqueFile*
</code></pre>
<p>使用<code>-i</code>开关防止覆盖。你知道吗</p>
<p>这将非常适用于一小堆文件。你知道吗</p>
<h3>更健壮和自适应的<a href="/questions/tagged/find" class="post-tag" title="show questions tagged 'find'" rel="tag">find</a>语法</h3>
<p>或者使用查找:</p>
<pre><code>cd foo/bar/baz
find alpha_* -type f -mindepth 3 -exec mv -it alpha/beta/gamma/files {} +
</code></pre>
<p>使用<code>find</code>的优点是</p>
<ul>
<li>您可以添加许多标志,如<code>-name</code>、<code>-mtime</code>等等</li>
<li>find永远不会尝试将更多文件传递给命令行可以容纳的命令(<code>mv</code>)。你知道吗</li>
</ul>
<h3><code>cp -al</code>特定的<strong><em>UN*X</em></strong>概念</h3>
<p>在Un*x下,您可以为同一inode创建<em>硬链接</em>,它不是符号链接,而是文件夹树中的第二个条目。你知道吗</p>
<p>注:由于只需要引用一个inode,所以只能在同一个文件系统上工作。你知道吗</p>
<p>通过使用</p>
<pre><code>cp -ialt alpha/beta/gamma/files alpha_*/beta/gamma/files/uniqueFile*
</code></pre>
<p>您将在一个目录中复制所有inode引用,但每个inode引用只保留一个文件。你知道吗</p>
<h3>使用<a href="/questions/tagged/bash" class="post-tag" title="show questions tagged 'bash'" rel="tag">bash</a>的<em>globstar</em>功能:</h3>
<pre><code>cd foo/bar/baz
shopt -s globstar
cp -alit alpha/beta/gamma/files alpha_*/**/uniqueFile*
</code></pre>