Skip to content
Advertisement

Find command with size and time and sorted by timestamp

I have the following folder setup for example

A/file1.txt
B/file2.txt
B/file3.txt
.
.
.
NN/file100.txt

I need to recursively list them with file size, modification time and sorted by modification time recent first.

I have tried the below without size… Any pointers?

find . -printf "%Tc file* n" | sort -n

Advertisement

Answer

find . -name <pattern> -printf "%T+t%st%pn" | sort
  • %T+ – modification time (and date)
  • %s – size
  • %p – path of file
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement