Skip to content

Instantly share code, notes, and snippets.

@dominicmartineau
Created April 29, 2013 18:27
Show Gist options
  • Save dominicmartineau/5483639 to your computer and use it in GitHub Desktop.
Save dominicmartineau/5483639 to your computer and use it in GitHub Desktop.
Minify all CSS files of a directory...
#! /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