Skip to content

Instantly share code, notes, and snippets.

@mihaeu
Created January 3, 2016 17:18
Show Gist options
  • Save mihaeu/09f9ed70d16f2d498eaf to your computer and use it in GitHub Desktop.
Save mihaeu/09f9ed70d16f2d498eaf to your computer and use it in GitHub Desktop.
work in progress ... I'll be using this to print the source code of my live coding exam at university
author="Michael Haeuslmann"
path='/home/mike/workspace/pw-online-auction/'
save_path='\/home\/mike\/workspace\/pw-online-auction\/'
output="test.pdf"
printf "# Prüfung Professionelle Webentwicklung\n\nAuthor: $author\n\nDatum: `date`\n\n" > test.md
find $path -type f -name '*.php' -print0 | while IFS= read -r -d '' file; do
printf '%s\n' "$file"
printf "##" >> test.md
echo $file | sed "s/$save_path//" >> test.md
printf "\n" >> test.md
printf "\n" >> test.md
printf '```php' >> test.md
printf "\n" >> test.md
cat "$file" >> test.md
printf "\n" >> test.md
printf '```' >> test.md
printf "\n" >> test.md
printf "\n" >> test.md
done
pandoc test.md -o $output && rm test.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment