find-command:使用创建时间搜索 [英] find-command: search with created time

查看:17
本文介绍了find-command:使用创建时间搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到Jul 30 04:37"创建的内容并将它们移动到/tmp?有问题:

How can I find things created "Jul 30 04:37" and move them to /tmp? Something wrong:

find .  -ctime "0037043007" -exec mv {} /tmp +

推荐答案

查看 GNU find 手册(以及 时间输入格式信息).

See the GNU find manual (and the time input formats information too).

特别是 -newerct '30-Jul-2009 04:37' 选项似乎可以满足您的大部分需求.

In particular, the -newerct '30-Jul-2009 04:37' option seems to do most of what you want.

唯一的障碍是手册页暗示它适用于比给定时间严格的文件.这表明您需要使用绝对时间:

The only snag is that the man page implies that it works for files strictly newer than given time. That suggests you need to use the absolute time:

1248957000 = 2009-07-30 05:30:00  (TZ = US/Pacific = UTC-07:00)

-newerct @1248957000

这仍然留下了如何处理严格大于语义的问题.

This still leaves the problem of how to deal with the strictly greater than semantics.

-newerct @1248956999 -a ! -newerct @1248957001

这可行,但毫无疑问是混乱的(并假设您有工具可以从日期/时间值获取 Unix 时间戳).

This works, but is indisputably messy (and assumes you have tools to obtain the Unix timestamp from a date/time value).

您需要一个足够新的 find 版本才能正常工作(GNU findutils 4.4.2 是最新的).

You need a new enough version of find for this to work (GNU findutils 4.4.2 is current).

这篇关于find-command:使用创建时间搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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