Skip to content

Instantly share code, notes, and snippets.

@jdp
Created January 4, 2011 22:13
Show Gist options
  • Save jdp/765541 to your computer and use it in GitHub Desktop.
Save jdp/765541 to your computer and use it in GitHub Desktop.
Very dirty script to count selectors in a CSS file
#!/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
echo $cnt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment