|
|
|
¸®´ª½ºÆÁ Go Unix Power Tools Online Book
Go Bash Guide
|
|
Read No. 51 article |
2001-11-02 06:41:29 |
|
|
|
|
NickName |
Ç®ºñ´© |
Subject |
Àͽº Áñ°Üã±â¸¦ html·Î º¯È¯ÇÏ´Â ¼Ð½ºÅ©¸³Æ® |
|
|
±Û¾´ÀÌ: griffino
#!/bin/sh
# Áñ°Üã±âÀÇ ³»¿ëÀ» HTML·Î ¸¸µé¾îÁÖ´Â ¼Ð½ºÅ©¸³Æ®
# : Ãâ·Â ÆÄÀϸíÀ» ù¹ø° ÀÎÀÚ·Î ¹ÞÀ½
# OPTIONS
# target: <a>ű׿¡¼ target¼Ó¼ºÀ¸·Î µé¾î°¡´Â ºÎºÐ
# Æ÷ÇÔ½ÃÅ°Áö ¾ÊÀ¸·Á¸é, »ý·«ÇØÁÖ¸é µÊ
# bm_path: favorits Æú´õÀÇ Àý´ë°æ·Î
# default_filename: µðÆúÆ® Ãâ·Â ÆÄÀϸí
target="_blank"
bm_path="/mnt/c/WINDOWS/Favorites"
default_filename="output.html"
# Ãâ·Â ÆÄÀÏÀÇ Àý´ë°æ·Î¸¦ °áÁ¤
cur_path=$(pwd)
p1=$1
if [ "${p1#/}" != "$p1" ]; then # if start with /
output=$p1
elif [ "$p1" = "" ]; then
output="${cur_path}/$default_filename"
else
output="$cur_path/$1"
fi
# °°Àº À̸§ÀÇ µð·ºÅ丮 ȤÀº ÆÄÀÏÀÌ Á¸ÀçÇÏ´ÂÁö °Ë»ç
if [ -d $output ]; then
echo "There exists directory of same name!"
exit 1
fi
if [ -f $output ]; then
echo -n "Already existing file name. Overwrite? "
read ans
case "$ans" in
y | Y )
rm -f $output;;
* )
exit 1
esac
fi
# °³º° µð·ºÅ丮¿¡ ´ëÇØ *.url ÆÄÀϵéÀ» °Ë»çÇÏ´Â Àç±ÍÇÔ¼ö
harvest() {
# °øÅë ºÎºÐÀ» Á¦¿ÜÇÑ µð·ºÅ丮¸íÀ» Ãâ·Â
cur_dir=$(pwd)
title=${cur_dir#$bm_path}
if [ "$title" != "" ]; then
echo "directory $* entered"
echo >> $output
echo "<p><b>${title#/}</b><br>" >> $output
fi
for file1 in *
do
if [ "${file1%.url}" != "$file1" ]; then # if ends with .url
# *.url ÆÄÀϵ鿡 ´ëÇØ °Ë»ç
# ÆÄÀϸíÀ¸·ÎºÎÅÍ ¸µÅ© Á¦¸ñÀ» ÃßÃâ
url=""
name=${file1%.url}
# 'URL='·Î ½ÃÀÛÇÏ´Â ÇàÀ¸·ÎºÎÅÍ urlÀ» ÃßÃâ
for str1 in $(grep URL= "$file1")
do
if [ "${str1#URL=}" != "$str1" ]; then # if starts with URL=
url=${str1#URL=}
# echo "NAME: $name"
# echo "URL: $url"
fi
done
if [ "$url" != "" ]; then
if [ "$target" = "" ]; then
echo "<a href=\"$url\">$name</a><br>" >> $output
else
echo "<a href=\"$url\" target=\"$target\">$name</a><br>" >>
$output
fi
fi
fi
done
# ÇÏÀ§ µð·ºÅ丮¿¡ ´ëÇÑ Àç±ÍÈ£Ãâ
for dir in *
do
if [ -d "$dir" ]; then
cd "$dir"
harvest "$dir"
fi
done
cd ..
}
cd "$bm_path"
harvest
echo "Result saved as $output"
|
|
Page Loading [ 0.03 Sec ]
SQL Time [ 0 Sec ]
|
|
|