Created
September 4, 2018 12:27
-
-
Save probablyangg/2bf13b00413139866915522b5805a4e3 to your computer and use it in GitHub Desktop.
bash script to generate a pdf from .cpp (or any other language) files (concatenating their output with each source file) https://github.com/angelagilhotra/file-generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
target='/home/angg/code/mca209lab' | |
cd $target | |
find . -maxdepth 1 -type f -name '*.cpp' | while read CPPFILE | |
do | |
TITLE=$(basename $CPPFILE .cpp) | |
g++ $TITLE.cpp | |
enscript $CPPFILE --color=1 -C -Ecpp -B -t $TITLE -o - | ps2pdf - $TITLE.pdf | |
./a.out > $TITLE.txt && enscript -B $TITLE.txt -o - | ps2pdf - $TITLE.output.pdf | |
pdftk $TITLE.pdf $TITLE.output.pdf cat output $TITLE.final.pdf | |
rm $TITLE.output.pdf | |
rm $TITLE.pdf | |
done | |
today=`date +%j-%H-%M` | |
mkdir $today | |
pdftk *.pdf cat output $today.pdf | |
mv *.pdf ./file | |
mv *.cpp ./$today | |
rm *.txt | |
cd './file' | |
rm *.final.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment