Skip to content

Instantly share code, notes, and snippets.

@cedricbdev
cedricbdev / remove-images.sh
Last active September 21, 2020 13:40
A simple way to detect unused files in a project using git
#!/bin/sh
for FILE in $(git ls-files ./img); do
# echo files that should be removed
# git grep $(basename "$FILE") > /dev/null || echo "would remove $FILE"
# remove files that should be removed
git grep $(basename "$FILE") > /dev/null || git rm "$FILE"
done
# credit: https://tanzu.vmware.com/content/blog/a-simple-way-to-detect-unused-files-in-a-project-using-git