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