Skip to content

Instantly share code, notes, and snippets.

@jaydenseric
Last active December 14, 2019 10:14
Show Gist options
  • Save jaydenseric/71727464b6ac0274eacb to your computer and use it in GitHub Desktop.
Save jaydenseric/71727464b6ac0274eacb to your computer and use it in GitHub Desktop.
Find unused Sass variables via Terminal
#!/usr/bin/env bash
# Usage:
# 1. Save script in project.
# 2. Run "chmod +x find-unused-sass-variables.sh".
# 3. Run script, pointing to Sass directory: "./find-unused-sass-variables.sh ./scss".
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