#!/bin/bash base="index" #----------------------------------------------------------------------------- index="${base}.html" tmp="${base}-tmp.html" old="${base}-old.html" check_bin () { if [ ! -x "${1}" ]; then echo "ERROR: Cannot find required program: ${1}" exit 1 fi } get_filesize_text () { local bytes=$(${stat_bin} --format="%s" "${*}") local size=0 local units="" size="${bytes}" units="B" if [ "${bytes}" -gt 100000000000 ]; then size=$(echo "scale=2; ${bytes} / 100000000000" | ${bc_bin}) units="EB" elif [ "${bytes}" -gt 1000000000 ]; then size=$(echo "scale=2; ${bytes} / 1000000000" | ${bc_bin}) units="GB" elif [ "${bytes}" -gt 1000000 ]; then size=$(echo "scale=2; ${bytes} / 1000000" | ${bc_bin}) units="MB" elif [ "${bytes}" -gt 1000 ]; then size=$(echo "scale=2; ${bytes} / 1000" | ${bc_bin}) units="KB" fi echo "${size} ${units}" } cat_bin="/bin/cat" ; check_bin "${cat_bin}" ls_bin="/bin/ls" ; check_bin "${ls_bin}" sort_bin="/usr/bin/sort" ; check_bin "${sort_bin}" awk_bin="/usr/bin/awk" ; check_bin "${awk_bin}" sed_bin="/bin/sed" ; check_bin "${sed_bin}" basename_bin="/usr/bin/basename" ; check_bin "${basename_bin}" stat_bin="/usr/bin/stat" ; check_bin "${stat_bin}" bc_bin="/usr/bin/bc" ; check_bin "${bc_bin}" bg_color="d5f3bc" ${cat_bin} > ${tmp} << EOF