Skip to content

Instantly share code, notes, and snippets.

@aidenbenner
Last active October 18, 2017 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aidenbenner/a341aa0cdca30f576f6cc2fe5958fde1 to your computer and use it in GitHub Desktop.
Save aidenbenner/a341aa0cdca30f576f6cc2fe5958fde1 to your computer and use it in GitHub Desktop.
downloadAsgn.sh
#! /bin/bash
# downloads george files creates directory and inserts userid at the top of file
# usage bash downloadAsgn.sh [assignment_number]
ASSIGNMENT_NUMBER=$1
USER_ID="abenner" # Your user id here!
# pad with 0s
if [ $ASSIGNMENT_NUMBER -lt 10 ]
then
ASSIGNMENT_NUMBER=0$ASSIGNMENT_NUMBER
fi
MAX_QUESTION=10
BASE_URL="https://www.student.cs.uwaterloo.ca/~se212/asn/a${ASSIGNMENT_NUMBER}grg/a${ASSIGNMENT_NUMBER}q"
for((x = 1; x <= $MAX_QUESTION; x++))
do
if [ $x -lt 10 ]
then
URL="${BASE_URL}0${x}.grg"
else
URL="${BASE_URL}${x}.grg"
fi
wget $URL -P ./a$ASSIGNMENT_NUMBER
echo $URL
done
sed -i "1s/.*/#u $USER_ID/" ./a$ASSIGNMENT_NUMBER/*.grg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment