免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 901 | 回复: 0
打印 上一主题 下一主题

从linux的man中提取html格式文件做成chm电子书 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-03-25 11:26 |只看该作者 |倒序浏览
因为自己的需要,特写了个脚本从fc6中提取man文件做成html的chm格式电子书,脚本如下,最后的成型的版本可以在这里下载
linux-man CHM v1.1

#!/bin/bash
#This is a manual transform script
#it will transform all manuals to htmls
MAN2HTML=/usr/bin/man2html
MANPATH=/home/tt/man/man
GZ=/bin/gzip
TargetHtmlPath=/home/tt/pp
NUM=9
function createhtml()
{
    for (( i=1; i=NUM; i++ ));
    do
        dir="${MANPATH}${i}"    ##get target path
        if [ -d $dir ]
        then
        (
        cd $dir
        ${GZ} -dvf *.gz && ${MAN2HTML} ".*${i}"
        for file in *
        do
            if [ -f $file ]
            then
            ${MAN2HTML} $file >"${file}.html"
            fi
        done
        )
        fi
        
        dir2="${MANPATH}${i}p"    ##get target path
        if [ -d $dir2 ]
        then
        echo $dir2
        (
        cd $dir2 && ${GZ} -dvf *.gz && ${MAN2HTML} ".*${i}"
        for file in *
        do
            if [ -f $file ]
            then
            ${MAN2HTML} $file >"${file}.html"
            fi
        done
        )
        fi   
    done
}
function copyhtml()
{
    for (( i=1; i=NUM; i++ ));
    do
        dir="${MANPATH}${i}"    ##get target path
        if [ -d $dir ]
        then
        (
        cd $dir
        pwd
        #cp *.html ${TargetHtmlPath} -v
        for file in *.html
        do
            cp ${file} ${TargetHtmlPath} -v
        done
        )
        fi
            
        dir2="${MANPATH}${i}p"    ##get target path
        if [ -d dir2 ];
        then
        (
        cd $dir2
        pwd
        #cp *.html ${TargetHtmlPath} -v
        for file in *.html
        do
            cp ${file} ${TargetHtmlPath} -v
        done
        )
        fi
    done
}
#createhtml
copyhtml


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/19651/showart_507462.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP