Child pages
  • Finding newest or oldest file in directory tree
Skip to end of metadata
Go to start of metadata

Finding the newest or oldest file (rg. modification date) in a directory tree is not as easy as one might think ...

# older to newer
find . -type f -printf "%TY-%Tm-%Td %TX %p\n" |cut -c1-19,31- |sort


# newer to older: add -r to sort:
find . -type f -printf "%TY-%Tm-%Td %TX %p\n" |cut -c1-19,31- |sort -r


# timestamps keys for printf:
%a = access time
%C = status change
%T = modification time


  • No labels