Created
April 29, 2013 18:27
-
-
Save dominicmartineau/5483639 to your computer and use it in GitHub Desktop.
Minify all CSS files of a directory...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
for s in $(find path/to/css/ -iname *.css | grep -v "\.min.css") | |
do | |
FILEMIN=${s/.css/.min.css} | |
if [ -f $FILEMIN ] | |
then | |
rm $FILEMIN | |
fi | |
echo "Processing " $FILEMIN; | |
touch $FILEMIN | |
cat $s | sed -e 's/^[ \t]*//g; s/[ \t]*$//g; s/\([:{;,]\) /\1/g; s/ {/{/g; s/\/\*.*\*\///g; /^$/d' | sed -e :a -e '$!N; s/\n\(.\)/\1/; ta' > $FILEMIN | |
done | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment