从linux的man中提取html格式文件做成chm电子书

 
因为自己的需要,特写了个脚本从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
http://blog.chinaunix.net/space.php?uid=227715&do=blog&id=2114843

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值