explore-services/portal-2/minifyScript

37 lines
764 B
Plaintext
Executable File

if [ "$1" != "" ]; then
echo "Find html files in $1";
find $1 -name "*.html" -type f
echo " ";
echo " ";
echo " ";
files=( $(find $1 -name "*.html" -type f) )
echo " Minifying...";
echo " ";
total = 0;
for entry in $(find $1 -name "*.html" -type f)
do
echo
s=$(stat -c%s "$entry");
echo "Size of $entry = $s bytes.";
cat $entry | sed -e :a -re 's/<!--.*?-->//g;/<!--/N;//ba'| awk '{printf "%s",$0} END {print ""}' | tr -s " "> $entry".mini";
n=$entry".mini";
ns=$(stat -c%s "$n");
dif=$((s-ns));
total=$((total+dif));
echo Size of $n = $ns bytes.
done
for entry in $(find $1 -name "*.html" -type f)
do
echo
cat $entry".mini" > $entry;
rm $entry".mini";
done
echo Total size $total
else
echo "Give a path";
fi