How to find unused files in a project?

Asked

Viewed 200 times

1

We have a web project that has changed the layout several times and many files will no longer be used. However, since there are several developers using files at the same time, the old files were kept until all the changes were completed.

I need a command for Linux where it searches the names of the image files, css, html and etc from within a specific folder and lists all that are no longer used.

  • 1

    Complicated it. Is there nothing dynamic in the project? What if there are partial names, like in frameworks where you set up the extension in a location? What about frameworks that use naming conventions to automatically find files? This is a kind of thing that you can do, but it depends a lot on the technology. The ideal, from my point of view, would be to assemble some traceability document starting from the visible functionalities of the system and identifying which file is used and where. What is left is a candidate for exclusion.

  • The files I need to find are all static anyway, because they are basically just visual/layout change files.

  • It is not an issue properly classified as software project (design software). Removing this tag will make it easier to locate issues.

1 answer

2

This should list for you the files not accessed or modified in the last 30 days:

ls -l `find * -mtime +30`

You can change the number of days by changing the "+30" of the example to the desired number of days.

Maybe finding list old files this way can help you filter what you want.

  • The problem in this case is that for images and css this doesn’t work because they are only used, not changed.

  • You can try the same command by swapping -mtime for -atime

Browser other questions tagged

You are not signed in. Login or sign up in order to post.