Skip to content

Instantly share code, notes, and snippets.

@onwp
Created January 9, 2023 13:36
Show Gist options
  • Save onwp/63a7c58f46765d6875969f9a11446a0a to your computer and use it in GitHub Desktop.
Save onwp/63a7c58f46765d6875969f9a11446a0a to your computer and use it in GitHub Desktop.
Bash script to find unused SCSS variables
#!/usr/bin/env bash
# HOW TO USE
# Save code to file
# Run as "SCRIPT_FILE_NAME SASS_DIRECTORY"
# e.g "./find_unused_scss_variables.sh ./sass"
VAR_NAME_CHARS='A-Za-z0-9_-'
find "$1" -type f -name "*.scss" -exec grep -o "\$[$VAR_NAME_CHARS]*" {} ';' | sort | uniq -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment