使用Bash查找并复制文件 [英] find and copy file using Bash

查看:70
本文介绍了使用Bash查找并复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除以下以外,任何人都有另一种在bash中查找和复制文件的方式:

Anybody has an alternate way of finding and copying files in bash than:

find . -ctime -15 | awk '{print "cp " $1 " ../otherfolder/"}' | sh

我喜欢这种方式,因为它很灵活,因为我正在构建命令(可以通过任何命令执行)并在之后执行它.

I like this way because it's flexible, as I'm building my command (can by any command) and executing it after.

还有其他简化命令到文件列表的方法吗?

Are there other ways of streamlining commands to a list of files?

谢谢

推荐答案

我建议使用find-exec选项:

find . -ctime 15 -exec cp {} ../otherfolder \;

一如既往,请查阅联机帮助页以获得最佳结果.

As always, consult the manpage for best results.

这篇关于使用Bash查找并复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆