B / Y / U / S
HOME 웹 호스팅 도메인 매뉴얼 고객지원 설정정보 계정신청 2025-05-24 Saturday 
웹 호스팅
# 공지 사항
# 자주 묻는 질문
# 질문과 답변
# 가입 문의
커뮤니티
# 자유게시판
# 리눅스팁
# 아이큐 테스트
# 내홈 소개
# 겔러리
# 자료실

  리눅스팁  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"
Regist Addr [ 192.168.0.2 ] 목록보기 윗글 아랫글
정규표현식 [ 상세 검색 ]
Page Loading [ 0.03 Sec ] SQL Time [ 0 Sec ]

Copyleft 1999-2025 by JSBoard Open Project
Theme Designed by IDOO And follow GPL2

개인정보 취급방침 이용 약관 사이트 맵 어드민 관리