I was wondering if anyone knew how I could go about writing a
grep command that recursively finds files that are not being referenced/used in a specific file and/or a directory of files, and then delete them?
So for example if my file has this
<head> <link rel='stylesheet' href='path/to/a.css'/> <script src='path/to/a-min.js></script> </head>
And my folder has this
/assets -- /css ---- a.css ---- b.css -- /js ---- a-min.js ---- /b ------ b-min.js ---- /c ------ c-min.js
It will recursively delete all the ones not referenced in said file which would be
c-min.js. Of course if another file has those files referenced, it wouldn't delete them.
I use version control so it isn't an issue if they get deleted and it screws up but it would be nice if there was a simple command or automated way of doing this correctly. Advice on best practice?