How can I find things created “Jul 30 04:37” and move them to /tmp? Something wrong:
find . -ctime "0037043007" -exec mv {} /tmp +
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
See the GNU find manual (and the time input formats information too).
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 the given time. That suggests you need to use the absolute time:
This still leaves the problem of how to deal with the strictly greater than semantics.
This works, but is indisputably messy (and assumes you have tools to obtain the Unix timestamp from a date/time value).
You need a new enough version of
findfor this to work (GNU findutils 4.4.2 was current in July 2009; 4.9.0 is current in November 2023).Note that classic and POSIX
mvexpects the target directory to be the last argument. The GNUmv(1)command has the extraordinarily useful-t directoryoption that allows you to use:If there were several files to move, the
mv {} /tmp +in the question would not work, as noted by Arkady in their answer.Also note that historical Unix systems and current Linux systems do not record the "birth time" of a file — but macOS does and has done for a decade or so. The recorded times are access time ("atime"), data modification time ("mtime") and inode modification time ("ctime"). That’s what you’ve got — "mtime" is usually the best choice, but YMMV.