]> www.fi.muni.cz Git - aoc.git/blob - 2017/get.sh
Day 25: examining the input
[aoc.git] / 2017 / get.sh
1 #!/bin/bash
2
3 DAY=`date +%d|sed 's/ //g'`
4 test -n "$1" && DAY="$1"
5 FILE="$((2*DAY - 1))in.txt"
6 COOKIE=`cat cookie`
7
8 START="6:00:02"
9 MAXWAIT=300
10 STARTSEC=`date -d "$START" "+%s"`
11 NOW=`date "+%s"`
12 WAITSEC=`expr $STARTSEC - $NOW`
13
14 if [ $WAITSEC -gt 0 -a $WAITSEC -lt $MAXWAIT ]
15 then
16         echo "Waiting for $WAITSEC seconds till $START for getting $FILE ..."
17         sleep $WAITSEC
18 fi
19
20 URL="https://adventofcode.com/2017/day/$DAY/input"
21 echo
22 echo "Downloading $URL to $FILE"
23 curl -s -b "$COOKIE" "$URL" --output "$FILE"
24 echo ========================================================================
25 cat "$FILE"
26 echo ========================================================================
27 echo "lines words chars"
28 wc "$FILE"
29 echo