List all regular files in the disk sorted by modification time.
Hi: Let be the set of all regular files on my linux partition. I'd like
to list its elements in chronological order, with respect to modification time. Any simple way to do it? |
Code:
find /path -xdev -type f -printf "%Ts %p\n" | sort -n | awk '{print $2}' |
Thanks for your reply. But tell me, how could I have the same list, but with a second column displaying the modification date?
|
Technically, you could just remove the "| awk '{print $2}'", then it would print the "unix-time" (seconds since midnight at 1st Jan 1970). But I'm guessing you want something human readable. This should work
Code:
find ~/tmp -type f -printf "%TY-%Tm-%Td %TH:%TM:%TS %p\n" | sort You can change the time format to your liking (see `man 3 strftime`), but be careful with non-numerical time variables (eg. "03:16 AM" < "03:16 PM", but "Friday" < "Monday"). |
Terrific! Thanks a lot.
|
All times are GMT -5. The time now is 07:00 PM. |