Instantly share code, notes, and snippets.

@stawecki stawecki/todogen.sh
Created Sep 12, 2011

Embed
What would you like to do?
"TODO:" comment to HTML generator in bash (grep, awk)
#!/bin/bash
OUTFILE="TODO.html"
echo > $OUTFILE
echo "<html><head><style>li{padding:4px;}</style></head><body>" >> $OUTFILE
echo "<h1>${PWD##*/}</h1>" >> $OUTFILE # Header - Current directory
echo "<h2><tt>TODO:</tt></h2><ul>" >> $OUTFILE
grep -r -i "TODO" ./ | grep "//" > tododoc.temp
exec < "tododoc.temp"
while read LINE
do
AFILE=`echo $LINE | awk '{print substr($0,1,index($0,":")-1)}' `
if [[ $AFILE != *$0* ]] # Not this script!
then
ATODO=`echo $LINE | awk '{print substr($0,index($0,"TODO")+5)}' `
ADATE=`ls -l $AFILE | awk '{print $6 " " $7 " " $8 }'`
echo "<li><big> $ATODO </big><small><br/> in <b>$AFILE</b> (Modified $ADATE)</small></li>" >> $OUTFILE
fi
done
echo "</ul></body></html>" >> $OUTFILE
rm tododoc.temp
@stawecki

This comment has been minimized.

Copy link
Owner Author

stawecki commented Sep 12, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment