diff options
Diffstat (limited to 'backomp')
-rwxr-xr-x | backomp | 32 |
1 files changed, 14 insertions, 18 deletions
@@ -2,37 +2,33 @@ set -e -# FIXME: clean up repetition ! read -rd '' FILTER_AWK <<'EOF' function flr(n, s) { return int(n / s) * s } BEGIN { - if (match(retain, /([*0-9]+)h/, md)) hr = md[1] - if (match(retain, /([*0-9]+)d/, md)) dr = md[1] - if (match(retain, /([*0-9]+)w/, md)) wr = md[1] - if (match(retain, /([*0-9]+)m/, md)) mr = md[1] + split("h d w m", buckets) + for (i in buckets) + if (match(retain, "([*0-9]+)" buckets[i], md) && md[1]) + ret[buckets[i]] = md[1] } { t = mktime(gensub(/(.*\/|^)(.+)-(..)-(..)-(..)(..)(..)/, "\\2 \\3 \\4 \\5 \\6 \\7", 1), 1) - h = flr(t, 60*60) - d = flr(t, 24*60*60) - m = mktime(strftime("%Y %m", t, 1) " 01 00 00 00", 1) - w = m + flr(t - m, 7*24*60*60) -} + bt["h"] = flr(t, 60*60) + bt["d"] = flr(t, 24*60*60) + bt["m"] = mktime(strftime("%Y %m", t, 1) " 01 00 00 00", 1) + bt["w"] = m + flr(t - m, 7*24*60*60) -h in hkeep || hr == "*" || hc++ < hr { hkeep[h] = $1 } -d in dkeep || dr == "*" || dc++ < dr { dkeep[d] = $1 } -w in wkeep || wr == "*" || wc++ < wr { wkeep[w] = $1 } -m in mkeep || mr == "*" || mc++ < mr { mkeep[m] = $1 } + for (b in ret) + if ((b, bt[b]) in bkeep || ret[b] == "*" || bc[b]++ < ret[b]) + bkeep[b, bt[b]] = $1 +} END { - for (i in hkeep) keep[hkeep[i]]++ - for (i in dkeep) keep[dkeep[i]]++ - for (i in wkeep) keep[wkeep[i]]++ - for (i in mkeep) keep[mkeep[i]]++ + for (i in bkeep) + ++keep[bkeep[i]] asorti(keep) for (i in keep) print keep[i] |