Skip to content

Instantly share code, notes, and snippets.

@hpbuniat
Created June 3, 2011 10:51
Show Gist options
  • Save hpbuniat/1006170 to your computer and use it in GitHub Desktop.
Save hpbuniat/1006170 to your computer and use it in GitHub Desktop.
Alpha Version of CSS-Shredder inspired by Nicole Sullivan-Haas
#!/bin/bash
IFS=$'\n'
echo "CSS-Shredder"
echo "---------------------------------------------------"
if [ -z "$1" ]; then
echo "Name des Ordners?"
read PORTAL
else
PORTAL=$1
fi
if [ -z "$2" ]; then
cssPath=$PORTAL
else
cssPath=$2
fi
#get date an create stat-dir
now=$(date +"%d%m%Y")
wdir="${PORTAL}-css-stats-$now"
if [ -d $wdir ]; then
rm -rf $wdir
fi
mkdir $wdir
declare -A tests
tests["float"]="float"
tests["font-size"]="font-size"
for i in {1..6}; do
tests["h${i}"]="(^h${i}|[^[:alnum:]\._]h${i})[[:space:]{:\.>#]"
done
for i in "input" "button"; do
tests["${i}"]="(^${i}|[^[:alnum:]\._]${i})[[:space:]{:\.>#]"
done
tests["hover"]=":hover"
tests["margin0"]="margin:[^0;]*.0"
tests["padding0"]="padding:[^0;]*.0"
tests["important"]="!important"
tests["link-color"]="(^a|\Wa)[.#:[:space:]][[:alnum:]]?.*color"
# find files
for FILE in $(find $cssPath -type f -name "*.css"); do
for TEST in ${!tests[@]}; do
cat ${FILE} | egrep ${tests["$TEST"]} >> "$wdir/${TEST}.txt"
done
done
#goto stat-dir
cd $wdir
#summary
wc -l *
wc -l * > overall.txt
echo "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment