Skip to content

Instantly share code, notes, and snippets.

@adililhan
Created October 12, 2012 22:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adililhan/3882070 to your computer and use it in GitHub Desktop.
Save adililhan/3882070 to your computer and use it in GitHub Desktop.
Simple CSS Compressor
#!/bin/bash
# Author: Adil İlhan
files=`find . -name "*.css"`;
for i in $files
do
rmcss=`ls -d $i | sed s/\.css//g`
`cp $i $rmcss".uncompressed.css"`
`sed 's/^\/.*//g;s/^\*.*//g;/ \*/d;s/^[A-Z].*//g' $i > tmp && mv tmp $i`
`cat $i | tr '\n' ' ' < $i | sed 's/[ \t]\+/ /g;s/{ /{/g;s/ }/}/g;s/} \./}./g;s/} #/}#/g;s/: /:/g' > tmp && mv tmp $i`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment