Skip to content

Instantly share code, notes, and snippets.

@rstriquer
Last active January 17, 2019 01:36
Show Gist options
  • Save rstriquer/a70cd5f470a3ca6a8d6dd207c5ba77f8 to your computer and use it in GitHub Desktop.
Save rstriquer/a70cd5f470a3ca6a8d6dd207c5ba77f8 to your computer and use it in GitHub Desktop.
Find all css and javascript files in pwd filesystem and minify them all using cssminifier.com and jpgoptimiser.com creating the "min" files all around
#!/bin/bash
#files=`find "$PWD" -type f \( -name \*.css -o -name \*.js \) | grep -vP '^(.*).min.css$' | grep -vP '^(.*).min.js$'` # pega todos os arquivos
files=`find "$PWD" -type f \( -name \*.css -o -name \*.js \) -mmin -30 | grep -vP '^(.*).min.css$' | grep -vP '^(.*).min.js$'` # pega todos os arquivos
for file in $files; do
extention="${file##*.}"
if [ "css" == "$extention" ]; then
dname="${file%/*}"
fname="${file##*/}"
fname="${fname%.*}"
echo "dname: "$dname" fname: "$fname" extention: "$extention
echo " \- gerando arquivos e postando"
cd $dname
filefrom=$fname"."$extention
fileto=$fname".min."$extention
curl -X POST -s --data-urlencode "input@${filefrom}" https://cssminifier.com/raw > $fileto
echo " \- Arquivo "$fileto" criado a partir do arquivo "$filefrom
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment