Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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