在 bash 中移动多个通配符的最有效方法是什么?
重写以下内容的最有效方法是什么:
mv *.jpg ~/Pictures && mv *.gif ~/Pictures && mv *.png ~/Pictures
What's the most efficient way to rewrite the following:
mv *.jpg ~/Pictures && mv *.gif ~/Pictures && mv *.png ~/Pictures
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以分组为一个
如果您担心文件太多导致参数列表太长,
You can group into one
If you are worrying too many files causing argument list too long
高效的?文件名计算的任何效率都可能会被实际复制所淹没,但您可以尝试:
如果您正在谈论大量文件,则必须小心吹错命令行大小限制,但是您可能会考虑使用
find
和xargs
(我不会通过完整描述来使解决方案复杂化,特别是因为可能有一个回答其他地方的扩展问题SO 网络)。Efficient? Any efficiencies in the calculations of the file names is likely to be swamped by the actual copying, but you could try:
If you're talking a lot of files, you'll have to watch out for blowing the command line size limit, but then you'd probably look into using
find
andxargs
(I won't complicate the solution by describing that fully, especially since there's probably an answer to that expanded question elsewhere on the SO network).