Skip to content

Instantly share code, notes, and snippets.

@jamesrr39
Last active August 29, 2015 14:21
Show Gist options
  • Save jamesrr39/8eca23bdecd54ab700ef to your computer and use it in GitHub Desktop.
Save jamesrr39/8eca23bdecd54ab700ef to your computer and use it in GitHub Desktop.
Find unused resources
#!/bin/bash
# a script to find any javascripts that may not be used anywhere anymore.
base_directory="."
all_files=$(find "$base_directory" -type f)
for file in $all_files
do
import_name=$(echo "$file" | rev | cut -d "/" -f 1 | rev | sed -e 's/\.js$//')
if [ $(grep -R "$import_name" . | wc -l) -eq 0 ];
then
echo "unused:$file";
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment