Skip to content

Instantly share code, notes, and snippets.

@hamidzr
Last active April 24, 2017 18:10
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 hamidzr/ae21587a165d368fc4c7477afb6ae31c to your computer and use it in GitHub Desktop.
Save hamidzr/ae21587a165d368fc4c7477afb6ae31c to your computer and use it in GitHub Desktop.
a helper to combine readme files for cs2201 (Vanderbilt)
#!/bin/bash
# rename each student's readmefile to his/her score and save to a single directory
# depends on these tools: bash, file, grep, unzip, sed
#relative output file address
output='readmes.txt'
echo '' > $output
for filename in *.*; do
printf '\n====== Begin student readme =======\n'>> $output
if file $filename | grep -iq word ; then
unzip -p $filename word/document.xml | sed -e 's/<\/w:p>/\n/g; s/<[^>]\{1,\}>//g; s/[^[:print:]\n]\{1,\}//g' >> $output
else
cat $filename >> $output
fi
printf "\n\n..:: Score: $filename ::.." >> $output
printf '\n====== End of student readme =======\n\n\n\n'>> $output
done
echo "combined file generated at $output"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment