User:Ulaaneot: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Ulaaneot (talk | contribs)
Created page with '<source lang="bash"> #!/bin/bash #autor: Urmo Laaneots #Versioon: 0.1 #Skript otsib üles kõik .html failid ja kirjutab faili esimese rea ja aadressi faili failid.html. # Määr…'
 
Ulaaneot (talk | contribs)
No edit summary
Line 7: Line 7:
FILENAME=failid.html
FILENAME=failid.html
# Loome html faili alguse vastavalt W3 standarditele ja kirjutame selle faili
# Loome html faili alguse vastavalt W3 standarditele ja kirjutame selle faili
echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">
  "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<html>
<head>
<head>

Revision as of 22:47, 26 May 2011

#!/bin/bash
#autor: Urmo Laaneots
#Versioon: 0.1
#Skript otsib üles kõik .html failid ja kirjutab faili esimese rea ja aadressi faili failid.html.
# Määrame failinime, kuhu lõpptulemus kirjutatakse
FILENAME=failid.html
# Loome html faili alguse vastavalt W3 standarditele ja kirjutame selle faili
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">
<html>
<head>
<title>.html failid</title>
<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" /> 
</head>
<body>" > $FILENAME
# `Otsime kõik .html failid süsteemist ja paneme need temp faili.
echo `find / -name "*.html" > temp`
# Loeb rida haaval temp faili.
while read line
do
	# Kirjutame failiaadressi temp2 faili
	echo $line > temp2
	# Tsükkel, mis avab faili ja loeb esimese rea ning kirjutab faili aadressi .html faili.
	while read line
	do
		FIRSTLINE=`head -n 1 $line`
		echo "Faili esimene rida: <textarea>$FIRSTLINE</textarea><br />" >> $FILENAME
		echo "Faili asukoht: <a href="$line" target="_new">$line</a><br />" >> $FILENAME
		echo " "
	done < temp2
done < temp
# Lõpetame .html faili
echo "</body>
</html>" >> $FILENAME
# Kustutame temp failid
rm temp
rm temp2