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

查看:13
本文介绍了使用 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 选项:

I would recommend using find's -exec option:

找到 .-ctime 15 -exec cp {} ../otherfolder ;

与往常一样,请查阅手册页以获得最佳结果.

As always, consult the manpage for best results.

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

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