"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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Here's a screenshot :] http://www.stawecki.com/2011/09/todo-comment-to-html-generator-in-bash/