Skip to content

Instantly share code, notes, and snippets.

@stawecki
Created September 12, 2011 21:40
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 stawecki/1212539 to your computer and use it in GitHub Desktop.
Save stawecki/1212539 to your computer and use it in GitHub Desktop.
"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
Copy link
Author

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