With a find
command, I can display directories names with multiple levels. The following command display all directories under /var
path with a depth of 2:
JavaScript
x
find /var -maxdepth 2 -type d;
The result shows:
JavaScript
/var
/var/log
/var/log/sssd
/var/log/samba
/var/log/audit
/var/log/ConsoleKit
/var/log/gdm
/var/log/sa
With a stat
command, I can find the modified date time:
JavaScript
stat /var/log/samba | grep 'Modify:'
The result is:
JavaScript
Modify: 2014-01-02 11:21:27.762346214 -0800
Is there a way to combine the two commands so that directories will be listed with modified date time?
Advertisement
Answer
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.