Created
August 9, 2013 07:57
-
-
Save dz1984/6191883 to your computer and use it in GitHub Desktop.
產生index.html網頁,將資料夾下所有的Code File全部建立結連結,可以快速在各程式間移動。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 收集練習的PHP Code產生連結到index.html裡,可以切換到不同的綀習程式。 | |
DEBUG=false; | |
TITLE="Tutorial code of PHP"; | |
HEADER="List PHP Code"; | |
HTML_FILE="index.html"; | |
# 建立PHP的超連結 | |
for FILE in `ls -1 t*.php`; do | |
COMMENT=`head -10 $FILE | grep -P "/\*\n.+\n\*/"`; | |
LINKS="<li><span>$COMMENT</span><br><a href='$FILE'>$FILE</a></li>\n"; | |
FILE_URL="$FILE_URL$LINKS" | |
if $DEBUG; then | |
echo "COMMET:$COMMENT" | |
echo "LINKS:$LINKS" | |
echo "FILE_URL:$FILE_URL" | |
fi | |
done | |
cat<<EOT >$HTML_FILE | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>$TITLE</title> | |
<meta http-equiv="content-type" content="text/html;charset=utf-8" /> | |
</head> | |
<body> | |
<h3>$HEADER</h3> | |
<hr> | |
<ol> | |
`echo -e $FILE_URL` | |
</ol> | |
</body> | |
</html> | |
EOT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment