Convert all Linux man pages to text / html or markdown
Yes... To convert one of them, say, man of man:
zcat /usr/share/man/man1/man.1.gz | groff -mandoc -Thtml
If you want 'all of installed on your PC', you just iterate through them. For different output (text, for example), use different 'device' (the -T argument).
Just in case... if the 'iteration' was the real problem, you can use:
OUT_DIR=...for i in `find -name '*.gz'`; do dname=`dirname $i` mkdir -p $OUT_DIR/$dname zcat $i | groff -mandoc -Thtml > $OUT_DIR/$i.htmldone
Use the command man -k ''
could list all man-page names available, which might be better than find
and zcat
original man-page data files; Meanwhile, the command of man has an option -T, --troff-device[=DEVICE]
that can generates HTML of given man-page section and name. So the following bash script comes to convert all man-pages available in your Linux into HTML files:
man -k '' | while read sLine; do declare sName=$(echo $sLine | cut -d' ' -f1) declare sSection=$(echo $sLine | cut -d')' -f1|cut -d'(' -f2) echo "converting ${sName}(${sSection}) to ${sName}.${sSection}.html ..." man -Thtml ${sSection} ${sName} > ${sName}.${sSection}.htmldone
In a intranet without Internet access that online man-pages service is unavailable, put this files in your static HTTP server such as Nginx with autoindex on is a good option, where browse and Ctrl+F may convenient.