Click to See Complete Forum and Search --> : [SOLVED] List Files From today


jblaha
04-01-2005, 04:01 PM
All,

What shell comand can I execute to give me a list of all files in a given directory that have been created or modified today.

Regards,
James Blaha

jblaha
04-01-2005, 04:47 PM
All,

Getting closer

find . -atime +1 -name '*' | xargs ls -lt

-jb

palinux
04-01-2005, 06:53 PM
Close. Using "atime +1" gives you files accessed more than 1*24 hours ago, which is the opposite of what you want.

You need the "-anewer filename" option which says show me all files which are accessed after (ie: newer than) the file named "filename".

So, first create the file in question using the touch command like this:

touch /tmp/file1 -t 200504010000

format is -t yyyymmddhhmm. Make it what you want.

Then on the find command:

find / -anewer /tmp/file1 -exec ls -l {} \;

xargs is nice, but find has enough options to make it redundant.

You might also need to -cnewer option, though I suspect that atime will cover it all.

bwkaz
04-01-2005, 07:57 PM
-anewer will give you all the files that have been "accessed" today, not all the files that have been "modified or created" today. You want to use -newer instead, to get that.

(A file's mtime is the time it was last written to (or whatever the mtime was set to with the "touch" command). A file's atime is the last time it was opened (for either reading or writing). A file's ctime is the last time the file's inode was modified -- which might be the creation time, if the file's permissions, disk position, and a bunch of other things haven't been changed since then. You want mtime, so you should use -newer.)

jblaha
04-04-2005, 09:02 AM
All,

Thank you very much for your posts!

Regards,
-jb