#!/bin/bash
echo "Donnez le nom du dossier contenant les fichiers de liens http : "; 
read dossier; 
echo "Donnez le nom du fichier html où stocker ces liens dans des tableaux : "; 
read tablo; 
echo "Donne le motif recherché sur les pages originales : "; 
read motif;
echo "<html><head><title>tableau de liens</title></head><body>" > $tablo; 
i=1
for fichier in `ls $dossier`
{
    echo "<table border=1>" >> $tablo; 
    
    echo "<tr><td align="center" bgcolor=\"silver\" colspan=\"4\"><b>Fichier $fichier</b></td></tr>" >> $tablo;
    for nom in `cat $dossier/$fichier` 
    {
	wget -O ./PAGES-ASPIREES/$i.html $nom
	lynx -dump $nom > ./DUMP-TEXT/$i.txt
	egrep -i "\b$motif\b" ./DUMP-TEXT/$i.txt > ./CONTEXTES/$i.txt
	echo "<tr><td><a href=\"$nom\">$nom</a></td><td><a href=\"../PAGES-ASPIREES/$i.html\">PAGE ASPIREE</a></td><td><a href=\"../DUMP-TEXT/$i.txt\">PAGE DUMP</a></td><td><a href=\"../CONTEXTES/$i.txt\">PAGE CONTEXTE</a></td></tr>" >> $tablo; 
	let "i+=1" ;
    }

    echo "</table>" >> $tablo;
    echo "<br>" >> $tablo;

}
echo "</body></html>" >> $tablo;

