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