Created
December 9, 2022 22:03
-
-
Save matthewsimo/88a6b494177ec7564516e12bc024ef15 to your computer and use it in GitHub Desktop.
Download the aoc input for a day
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# example usage: `$ ./get_input.sh 09` | |
echo "getting input file for day ${1}"; | |
PATH="input/${1}.txt"; | |
YEAR="2022"; | |
DAY=$(echo "${1}" | /usr/bin/sed 's/^0*//'); | |
URL="https://adventofcode.com/${YEAR}/day/${DAY}/input"; | |
# Download input | |
/usr/bin/curl --cookie 'session={add_your_token_here};' $URL > $PATH | |
# Trim trailing new line | |
/usr/bin/perl -pi -e 'chomp if eof' $PATH |
I'm calling this from another script so I need to use full path to all these commands, change if you're calling this directly or your system doesn't match!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't forget to:
chmod u+x ...
wherever you put this