Skip to content
Advertisement

get most recent file (with same name) in subdirectories

Suppose you have 10 projects in subdirectories project_1, …, project_10, all in parent directory projects.
All projects use the same lib, in project/project_n/lib/mylib
For particuliar reasons, mylib has to be copied in each project directory.
mylib files are modified from time to time when working in different projects. But usually modified on one project and not propagated on others.

I want to see the most recent file (for a given filename), scanning all projects. How would you do it?

Advertisement

Answer

In your specific case, I guess there is a small trick you would like to know:

The wildcards (such as *) could also match the directory name.

So simply do:

ls -lt project/project_*/lib/mylib/filename

You could locate your file in the project_1/ first with Tab skill very fast, then replace the 1 with *.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement