Asked • 06/21/19

How to recursively find and list the latest modified files in a directory with subdirectories and times?

- Operating system: Linux - Filesystem type: ext3 - Preferred solution: bash (script/oneliner), ruby, python I have several directories with several subdirectories and files in them. I need to make a list of all these directories that is constructed in a way such that every first-level directory is listed next to the date and time of the latest created/modified file within it. To clarify, if I touch a file or modify its contents a few subdirectory levels down, that timestamp should be displayed next to the first-level directory name. Say I have a directory structured like this: ./alfa/beta/gamma/example.txt and I modify the contents of the file `example.txt`, I need that time displayed next to the first-level directory `alfa` in human readable form, not epoch. I've tried some things using find, `xargs`, `sort` and the likes but I can't get around the problem that the filesystem timestamp of 'alfa' doesn't change when I create/modify files a few levels down.

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.