Skip to main content
OP asked re "last modified date", but didn't say whether this was to be oldest to newest or newest to oldest. This addition covers the former option.n
Source Link
Seamus
  • 3.9k
  • 2
  • 21
  • 49

If you want to flatten the directory structure (thus sorting by date over all files in all directories, ignoring what directory the files are in) the find-approach suggested by @yeti is the way to go. If you want to preserve directory structure, you might try

$ ls -ltR /path/to/directory 

which sorts directory based.

Alternatively, if you want a recursive (-R) listing, and you want the files listed in reverse (-r) order (i.e. from oldest to newest):

$ ls -ltrR /path/to/directory 

If you want to flatten the directory structure (thus sorting by date over all files in all directories, ignoring what directory the files are in) the find-approach suggested by @yeti is the way to go. If you want to preserve directory structure, you might try

$ ls -ltR /path/to/directory 

which sorts directory based.

If you want to flatten the directory structure (thus sorting by date over all files in all directories, ignoring what directory the files are in) the find-approach suggested by @yeti is the way to go. If you want to preserve directory structure, you might try

$ ls -ltR /path/to/directory 

which sorts directory based.

Alternatively, if you want a recursive (-R) listing, and you want the files listed in reverse (-r) order (i.e. from oldest to newest):

$ ls -ltrR /path/to/directory 
Source Link
Andreas Wiese
  • 10.8k
  • 1
  • 35
  • 39

If you want to flatten the directory structure (thus sorting by date over all files in all directories, ignoring what directory the files are in) the find-approach suggested by @yeti is the way to go. If you want to preserve directory structure, you might try

$ ls -ltR /path/to/directory 

which sorts directory based.