summary refs log tree commit diff stats
path: root/fwendplanet.sh
diff options
context:
space:
mode:
Diffstat (limited to 'fwendplanet.sh')
-rwxr-xr-xfwendplanet.sh31
1 files changed, 25 insertions, 6 deletions
diff --git a/fwendplanet.sh b/fwendplanet.sh index 586f934..7ec7eb8 100755 --- a/fwendplanet.sh +++ b/fwendplanet.sh
@@ -6,12 +6,31 @@ curd="$PWD"
6cd "$1" || return 1 6cd "$1" || return 1
7 7
8if [ -n "$2" ]; then 8if [ -n "$2" ]; then
9 old="$(($(date +%s) - ($2 * 24 * 3600)))" 9 page="$2"
10else 10else
11 old=0 11 page=1
12fi 12fi
13 13
14awk -v old="$old" \ 14if [ -n "$3" ]; then
15 'BEGIN{FS="\t";OFS="\t";} int($1)>=old{$2="["FILENAME"] "$2;print}' * | 15 groupn="$(($3 * 24 * 3600))"
16 sort -k1,1rn | 16else
17 "$curd/fwendplanet_html.awk" 17 groupn=1
18fi
19
20# echo "$@" "$page" "$groupn" >&2
21
22awk -v page="$page" -v groupn="$groupn" -v now="$(date +%s)" \
23 'BEGIN { FS = "\t"; OFS = "\t"; }
24 {
25 oldest = groupn*page
26 if (oldest) oldest=now-oldest; else oldest=0
27 newest = groupn*(page-1)
28 if (newest) newest=now-newest; else newest=now
29 d=int($1)
30 if (d>oldest && d<=newest) {
31 # printf "%s\t%s\t%s\n", d, oldest, newest > "/dev/stderr"
32 $2 = "[" FILENAME "] " $2
33 print
34 }
35 }
36' * | sort -k1,1rn | "$curd/fwendplanet_html.awk"