views:

116

answers:

3

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

find .  -ctime "0037043007" -exec mv {} /tmp +
+2  A: 
for file in $(ls -lR | grep "Jul 14" | awk '{print $9}')
do
mv $file /tmp
done
ennuikiller
Please, note my goal updated. I know the files, but I am unable to move them with the criterian: creation time.
Masi
*specific creating time, not smaller than or greater than.
Masi
A: 

I am not sure why you are using the "exec {} +" syntax... How about this:

find . -ctime "0037043007" -exec mv \{} /tmp/ \;
scrible
+1  A: 

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 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

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 find for this to work (GNU findutils 4.4.2 is current).

Jonathan Leffler
I opened a new question about timestamps here: http://stackoverflow.com/questions/1204669/easiest-way-to-generate-unix-timestamp. They are new for me.
Masi