在无意间发现了这么给力的一个shell脚本,脚本本身并不复杂,用到的技巧也不多,但不得不给这种思路点个赞!自己在Linux系统上测试了,效果不错,后期可能会根据需要修改一下前端的展示(其实也就是多设置几个HTML属性),但是就现在来说,已经非常实用了:
#! /bin/bash helpDir=man_pages main_file=./$helpDir/index.html cmds=` { for j in ${PATH//:/ } do ls $j done } | sort | uniq ` rm -f -r $helpDir mkdir $helpDir echo "<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> " >> $main_file echo "<table border="1"><tr><th>命令</th><th>描述</th></tr>" >> $main_file for i in $cmds do echo "processing "$i"..." file=./$helpDir/${i}.html echo "<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> " >> $file echo "<p><a href="index.html">返回目录</a></p>" >> $file echo "<hr>" >> $file echo "<pre>" >> $file man $i >> $file 2>/dev/null && { echo "</pre>" >> $file describ=`sed -n -e '/NAME/ {n;p;q}' $file | cut -f 2 -d '-'` echo "<tr>" >> $main_file echo "<td><a href="$i.html">$i</a></td>" >> $main_file echo "<td>$describ</td>" >> $main_file echo "</tr>" >> $main_file } || rm $file done echo "</table>" >> $main_file
《 “用shell脚本生成所有命令的说明文档[bak]” 》 有 2 条评论
为Dash添加Linux的Man Pages
https://www.binss.me/blog/add-linux-man-pages-to-dash/
https://blog.kapeli.com/linux-man-pages-in-dash
https://gist.githubusercontent.com/steakknife/7969875/raw/make_man_tarball.sh
`
$ man -w
$ manpath
`
各Linux发行版都是如何列出已安装了哪些软件列表的
https://unix.stackexchange.com/questions/20979/how-do-i-list-all-installed-programs
`
for d in ${PATH//:/ } ; do
for f in $d/* ; do
test -x $f && test -f $f && echo $f
done
done
`