TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The power of find and xargs

4 点作者 rbxbx将近 15 年前

2 条评论

tange将近 15 年前
xargs cannot replace {} with a lot of arguments, so if mv did not have --target-directory, then xargs would have to do:<p><pre><code> find ... | xargs -0 -i {} mv {} ~/Pictures </code></pre> which would run one mv per file.<p>GNU Parallel <a href="http://www.gnu.org/software/parallel/" rel="nofollow">http://www.gnu.org/software/parallel/</a> allows for replacing {} with multiple arguments. So this would do the right thing:<p><pre><code> find ... | parallel -X -0 mv {} ~/Pictures </code></pre> GNU Parallel is useful for many other applications. Watch the intro video to learn more: <a href="http://www.youtube.com/watch?v=OpaiGYxkSuQ" rel="nofollow">http://www.youtube.com/watch?v=OpaiGYxkSuQ</a>
alextingle将近 15 年前
The examples are somewhat forced:<p><pre><code> find ~/Desktop -name "*.jpg" -o -name "*.gif" -o -name "*.png" \ -print0 | xargs -0 mv --target-directory ~/Pictures </code></pre> What's wrong with this?...<p><pre><code> mv ~/Desktop/**/*.{jpg,gif,png} ~/Pictures</code></pre>
评论 #1500575 未加载
评论 #1501358 未加载