summary refs log tree commit diff stats
path: root/fwendplanet.sh
blob: 7ec7eb8146822a2f92da3dab61de594dd3e77580 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# make fwendplanet

curd="$PWD"

cd "$1" || return 1

if [ -n "$2" ]; then
	page="$2"
else
	page=1
fi

if [ -n "$3" ]; then
	groupn="$(($3 * 24 * 3600))"
else
	groupn=1
fi

# echo "$@" "$page" "$groupn" >&2

awk -v page="$page" -v groupn="$groupn" -v now="$(date +%s)" \
	'BEGIN { FS = "\t"; OFS = "\t"; }
		{
		oldest = groupn*page
		if (oldest) oldest=now-oldest; else oldest=0
		newest = groupn*(page-1)
		if (newest) newest=now-newest; else newest=now
		d=int($1)
		if (d>oldest && d<=newest) {
			# printf "%s\t%s\t%s\n", d, oldest, newest > "/dev/stderr"
			$2 = "[" FILENAME "] " $2
			print
		}
	}
' * | sort -k1,1rn | "$curd/fwendplanet_html.awk"