在linux中,可以利用系统提供的man2html命令,将linux命令的man手册转成html代码,将下面的源码保存为man2html.sh,这个脚本可以将man批量转化成html代码。
if [ $# -eq 0 ]then echo "Usage: ./man2html.sh /path/to/man/dirctory /path/to/html/output/dirctory" echo "Exampe: ./man2html.sh /usr/share/man/man1 /tmp/html1"fidir=/usr/share/man/man1output=/tmp/html1if [ $# -eq 1 ]then dir=$1elif [ $# -eq 2 ]then dir=$1 output=$2fiecho "./man2html.sh ${dir} ${output}"if [ ! -d $output ]then mkdir -p $outputfiif [ -d $dir ]then mkdir -p /tmp/unzipped cd $dir for f in *.gz; do if [ -f $f ] then filename=$(basename "${f}" .gz) unzipfile="/tmp/unzipped/${filename}" outputfilename="${output}/${filename}.html" gunzip -c "${f}" > ${unzipfile} man2html ${unzipfile} > ${outputfilename} sed -i 's#^Content-type: text/html$##' ${outputfilename} sed -i 's#</HEAD>#<META charset="UTF-8"></HEAD>#' ${outputfilename} fi donefiecho "done!" |
man后面的数字说明
- User Commands
- System Calls
- C Library Functions
- Devices and Special Files
- File Formats and Conventions
- Games et. Al.
- Miscellanea
- System Administration tools and Deamons
man使用
man -k '^printf' man 1 printf man 3 printf man -a printf |