makeday.sh

 

#### makeday.sh
####
#### Description:
####
####   makeday.sh will recurse through a directory tree 
####   and find all html files with a timestamp within 
####   X number of days.  The results are written to html 
####   files in the current directory with names based on 
####   file dates
####
####   For example, running makeday.sh 3 on Sept 14 would find 
####   all files with a date stamp between Sep 11-14.  The name
####   of a file with a date stamp of Sep 12 would be written as
####   a hyperlink within a file called Sep_12.html.
####
#### Usage: 
####  
####    makeday.sh number_of_days
####
####



cd /usr/tomcat/webapps/ROOT/status
cat /dev/null > tmp2.out

find .. -name \*.html -daystart -mtime -$1 -print | \
grep -v bak\/ | \
grep -v analysis\/ | \
grep -v depot\/ | \
grep -v changelist\/ | \
grep -v \.log\/ | \
grep -v cal\/ > tmp.out


for i in `cat tmp.out`
do
    ls -l $i | cut -c44-500  |  sed "s/  / /" | sed "s/ /_/" >> tmp2.out
done

sort tmp2.out | cut -d" " -f1 | uniq > tmp3.out

i=`date | cut -c5-10 | sed "s/ /_/"`

for i in `cat tmp3.out`
do

    echo "Processing $i" 
    grep $i tmp2.out | cut -d" " -f3 > tmp4.out
    cp tmp4.out tmp5.out 
    cat /dev/null > tmpx.out
    for z in `cat tmp5.out`
    do
        y=`grep "<title>" $z | sed "s/<title>//" | sed "s/<\/title>//"`
        if [ "$y" == "" ] || [ "$y" == " " ]
        then 
            y=`basename $z .html`
        fi
        echo $y >> tmpx.out
    done
    paste tmp4.out tmpx.out > tmp6.out
    sed "s/^/<a href=\"/" tmp6.out | \
    sed "s/	/\">/" | \
    sed "s/$/<\/a><\/td><\/tr>/" > tmp7.out
    
    grep $i tmp2.out | \
    cut -d" " -f2,3  | \
    sort | \
    sed "s/^/<tr><td>/" | \
    sed "s/ /<\/td><td>/g" | cut -c1-22 > tmp8.out

    echo "Creating $i.html..." 

    cat /dev/null > $i.html
    x=`echo $i | sed "s/_/ /"`

    echo "<html> " >> $i.html
    echo "<head> " >> $i.html
    echo "   <META content=text/css http-equiv=Content-Style-Type> " >> $i.html
    echo "   <LINK href=\"lstyle.css\" rel=\"stylesheet\" type=\"text/css\"> " >> $i.html
    echo "   <title> $x </title> " >> $i.html
    echo "</head> " >> $i.html

    echo "   " >> $i.html
    echo "<body> " >> $i.html
    echo "<font class=grey2> " >> $i.html
    echo "<blockquote>" >> $i.html
    echo "<blockquote>" >> $i.html
    echo "   " >> $i.html
    echo "<p>&nbsp;</p> " >> $i.html
    echo "<h1>$x, 2001</h1> " >> $i.html

    echo "<p><hr> " >> $i.html

    echo " " >> $i.html

    echo " " >> $i.html
    echo "<p><table cellspacing=6> " >> $i.html
    echo "<tr><th align=left>Completed</th><th align=left> Description</th></tr>" >> $i.html

    paste tmp8.out tmp7.out  | sed "s/	//g" >> $i.html

    echo "</table>" >> $i.html 
    echo " " >> $i.html
    echo "<p><hr> " >> $i.html
    echo "<font class=grey2> " >> $i.html
    echo " " >> $i.html
    echo "<br> Copyright 2001. All Rights Reserved.  " >> $i.html
    echo "<script javascript=\"JavaScript\"> " >> $i.html
    echo "document.write(\"<br>Last updated: \"+document.lastModified); " >> $i.html
    echo "</script> " >> $i.html
    echo "   " >> $i.html
    echo "</blockquote>" >> $i.html
    echo "</blockquote>" >> $i.html
    echo "</body> " >> $i.html
    echo "</html> " >> $i.html
    echo "   " >> $i.html

done



#rm tmp*