Steve Holdoway wrote:

David Kirk wrote:

How do I list files created in a directory on a specified date?


You can use the find command with -exec ls {} \;

Unfortunately you can't search on when a file was created. Your options are:

  -atime - when the file was last accessed
  -ctime - when the file's status was last changed
  -mtime - when the file's contents were last changed

So, you could use eg:

  find /home/ross -ctime 1 -exec ls {} \;

to see what files ctime have changed in the last 24 hours.

'man find' to get more information.



...nearly!

find $dir -ctime -1 | xargs ls -ld | more

is faster ( xargs parcels up the files to ls, exec calls it anew every time ), and the -1 ( as opposed to 1 ) will find files less than 24 hours old ( as opposed to exactly 24 hours old ).

Cheers,


Steve mutter mutter gmail mutter mutter (:


following up on my own post ( alcohol poisoning is my excuse )...

1. ctime returns the last time the files status ( name, permissions... ) changed, which is not a 1:1 mapping with creation. mtime returns tha time of last modification ( content change )... is that any more use?

2. find $dir -ctime -2 -a -ctime +1  | xargs ls -ld | more

will list files 'created' more than 1 and less than 2 days ago. IIRC there's a -daystart(1) flag that converts to calendar dates, rather than offsets to now.


Cheers,

Steve
(1) I cheated, thought it was daytime, but used 'man find' to check (:

Reply via email to