Skip to content

Instantly share code, notes, and snippets.

@matthewsimo
Created December 9, 2022 22:03
Show Gist options
  • Save matthewsimo/88a6b494177ec7564516e12bc024ef15 to your computer and use it in GitHub Desktop.
Save matthewsimo/88a6b494177ec7564516e12bc024ef15 to your computer and use it in GitHub Desktop.
Download the aoc input for a day
#!/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
@matthewsimo
Copy link
Author

Don't forget to:

  1. Add your own session cookie
  2. chmod u+x ... wherever you put this

@matthewsimo
Copy link
Author

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