How to display modified date time with 'find' command?
Solution 1:
The accepted answer works but it's slow. There's no need to exec stat for each directory, find provides the modification date and you can just print it out directly. Here's an equivalent command that's considerably faster:
find /var -maxdepth 2 -type d -printf "%p %TY-%Tm-%Td %TH:%TM:%TS %Tz\n"
Solution 2:
You could use the -exec
switch for find
and define the output format of stat
using the -c
switch as follows:
find /var -maxdepth 2 -type d -exec stat -c "%n %y" {} \;
This should give the filename followed by its modification time on the same line of the output.