3 #########################################################################
4 # This program is free software: you can redistribute it and/or modify #
5 # it under the terms of the version 3 of the GNU General Public License #
6 # as published by the Free Software Foundation. #
8 # This program is distributed in the hope that it will be useful, but #
9 # WITHOUT ANY WARRANTY; without even the implied warranty of #
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
11 # General Public License for more details. #
13 # You should have received a copy of the GNU General Public License #
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
16 # Written by and Copyright (C) Francois Fleuret #
17 # Contact <francois@fleuret.org> for comments & bug reports #
18 #########################################################################
26 if [[ ${size} -lt 1024 ]]
29 elif [[ ${size} -lt 1048576 ]]
31 size_h=$(bc <<<"scale=1;${size} / 1024.0")Kb
32 elif [[ ${size} -lt 1073741824 ]]
34 size_h=$(bc <<<"scale=1;${size} / (1024.0*1024.0)")Mb
36 size_h=$(bc <<<"scale=2;${size} / (1024.0*1024.0*1024.0)")Gb
45 while [[ ${line} =~ @DATE ]]
48 line=$(sed -e "s/@DATE/${DATE}/" <<<"${line}")
51 while [[ ${line} =~ @EXEC ]]
53 command=$(sed -e "s/^.*@EXEC{\([^}]*\)}.*$/\1/" <<<"${line}")
54 prefix=$(sed -e "s/\(^.*\)@EXEC.*$/\1/" <<<"${line}")
55 suffix=$(sed -e "s/^.*@EXEC{[^}]*}\(.*\)$/\1/" <<<"${line}")
56 line=${prefix}$(${command})$suffix
59 while [[ ${line} =~ @SIZE ]]
61 filename=$(sed -e "s/^.*@SIZE{\([^}]*\)}.*$/\1/" <<<"${line}")
62 if [[ ${filename} =~ ^http ]]
64 filesize=$(curl -LsI "${filename}" | grep -i ^Content-Length: | sed -e 's/^[^:]*: \([0-9]*\).*$/\1/')
66 filesize=$(stat -c %s "${filename}")
68 filesize_h=$(hsize ${filesize})
69 line=$(sed -e "s/@SIZE{\([^}]*\)}/${filesize_h}/" <<<"${line}")
72 while [[ ${line} =~ @URLDATE ]]
74 filename=$(sed -e "s/^.*@URLDATE{\([^}]*\)}.*$/\1/" <<<"${line}")
75 timestamp=$(curl -Lv "${filename}" 2>&1 | \grep '^< Last-Modified:' | sed -e 's/^.*Last-Modified: *//')
76 timestamp=$(date -d "${timestamp}" +'%b %e, %Y')
77 line=$(sed -e "s/@URLDATE{\([^}]*\)}/${timestamp}/" <<<"${line}")
80 while [[ ${line} =~ @FILEDATE ]]
82 filename=$(sed -e "s/^.*@FILEDATE{\([^}]*\)}.*$/\1/" <<<"${line}")
83 filedate=$(date +'%b %e, %Y' -r "${filename}")
84 line=$(sed -e "s/@FILEDATE{\([^}]*\)}/${filedate}/" <<<"${line}")