Patrick Georgi | 274c6c2 | 2013-12-05 18:11:33 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # usage: $0 [weekly|monthly|quarterly] < filenames |
| 3 | # sorts files of the form VENDOR/BOARD/COMMIT/DATE/revision.txt |
| 4 | # into buckets of the given granularity |
| 5 | |
| 6 | weekly() { |
Patrick Georgi | 4777756 | 2014-01-02 09:19:21 +0100 | [diff] [blame] | 7 | date --date="$1" +%GW%V |
Patrick Georgi | 274c6c2 | 2013-12-05 18:11:33 +0100 | [diff] [blame] | 8 | } |
| 9 | |
| 10 | monthly() { |
| 11 | date --date="$1" +%Y-%m |
| 12 | } |
| 13 | |
| 14 | quarterly() { |
| 15 | date --date="$1" "+%Y %m" | awk '{ q=int(($2-1)/3+1); print $1 "Q" q}' |
| 16 | } |
| 17 | |
| 18 | # TODO: restrict $1 to allowed values |
| 19 | |
| 20 | curr="" |
| 21 | sort -r -k4 -t/ | while read file; do |
| 22 | timestamp=`printf $file | cut -d/ -f4` |
| 23 | new=`$1 $timestamp` |
| 24 | if [ "$new" != "$curr" ]; then |
| 25 | if [ "$curr" != "" ]; then |
| 26 | printf "\n" |
| 27 | fi |
| 28 | printf "$new:" |
| 29 | curr=$new |
| 30 | fi |
| 31 | printf "$file " |
| 32 | done |
| 33 | printf "\n" |