Skip to content

Instantly share code, notes, and snippets.

@ajaswa
Forked from jdp/csscount.sh
Last active December 20, 2015 18:29
Show Gist options
  • Save ajaswa/6176177 to your computer and use it in GitHub Desktop.
Save ajaswa/6176177 to your computer and use it in GitHub Desktop.
#!/bin/sh
cnt=0
depth=0
while read -n 1 char; do
case $char in
"{")
((depth++))
;;
"}")
((depth--))
if [ "$depth" -eq "0" ]; then
((cnt++))
fi
;;
",")
((cnt++))
;;
esac
done < $1
echo "Total number of selectors:" $cnt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment