41 lines
1.1 KiB
Bash
Executable File
41 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
#set -x
|
|
clear
|
|
########################################################################
|
|
###
|
|
##
|
|
#
|
|
# Author: Stéphane HUC
|
|
# mail: devs@stephane-huc.net
|
|
# gpg:fingerprint: CE2C CF7C AB68 0329 0D20 5F49 6135 D440 4D44 BD58
|
|
#
|
|
# License: Public Domain
|
|
#
|
|
# Git:
|
|
#
|
|
# Date: 2020/05/05
|
|
#
|
|
##
|
|
###
|
|
########################################################################
|
|
|
|
ROOT="$(dirname "$(readlink -f -- "$0")")"
|
|
|
|
########################################################################
|
|
printf '%s\n' "Write a root folder (where files exist to compress!): "
|
|
read -r dir_local
|
|
|
|
|
|
_gz() {
|
|
cd "${dir_local}" || exit 1
|
|
#find . -type f -regex '.*\.\(atom\|css\|html\|js\|svg\|txt\|xml\)$' -size +1024c -exec gzip -9 -f {} \;
|
|
find . -type f -size +1024c -a \( \
|
|
-name "*.css" -o -name "*.html" -o -name "*.js" \
|
|
-o -name "*.svg" -o -name "*.txt" -o -name "*.xml" \
|
|
\) | while read -r line; do echo "Compress ${line}"; brotli -Z "${line}"; gzip -9 -f < "${line}" > "${line}.gz"; done
|
|
#| while read -r file; do gzip -9 -f -v "${file}"; done
|
|
cd "$ROOT" || exit 1
|
|
}
|
|
|
|
_gz
|