Matt Price <matt.price@utoronto.ca> writes:
I have a directory that's gotten out of hand with several hundred
files. I'm looking foractive files, and normally would do
ls -tr
to find the most recently-modified files -- but the list is so huge
it's difficult. So I tried:
find . -maxdepth 1 -f file -atime -2
-atime looks at the access time, not the modification time.
but while this seems to return the right files (can't be sure) they're
not sorted by time. So what solutions do other people use?
Depending on whether you really mean the modification time or access
time,
find . -maxdepth 1 -type f -mtime -2 -printf '%TY-%Tm-%Td %TT %p\n' | sort
or
find . -maxdepth 1 -type f -atime -2 -printf '%AY-%Am-%Ad %AT %p\n' | sort
should work. (Assuming you have no files with newline characters in the
filename.)
Martin