当前位置: 首页 > 工具软件 > man2html > 使用案例 >

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

许毅
2023-12-01
 
因为自己的需要,特写了个脚本从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

 类似资料: