14

Is there anywhere one can get a copy of Ubuntu's man pages in e-reader (preferably Kindle/mobi, epub can be handled)format?

acp
  • 143

3 Answers3

8

This bash command will dump HTML files for every man page on the system. You'll need to install the groff package first, then cd to an empty directory and run:

for f in `ls -1 /usr/share/man/man*`; do n=`echo $f | sed s/[.].*[.]gz//`; man -Thtml $n > $n.html ; done

This will cycle through all of the files in the /usr/share/man directory, strip off the section number and the extension using sed, then call man to render the manpage to HTML (man -Thtml in turn calls groff, which is why you need it installed first), storing the result in an html file with the same name as the page. It will take a while to complete, and groff throws some warnings about line breaks, but when it finishes, you will have all of your man pages in HTML format.

Most e-readers can handle HTML files, but if yours doesn't, you can use calibre to convert the HTML files to mobi or epub or any other format you choose.

cscarney
  • 18,963
  • 1
    You can try also man -Tdvi and dvi2pdf after that to get a bunch of PDFs. – ulidtko Jan 17 '11 at 11:32
  • Sounds excellent. I knew there was a way to get PDF output, but PDFs don't reflow well – acp Jan 17 '11 at 14:15
  • I've had pretty good luck using Calibre to convert pdf's for my kindle and android. (Text and html convert well, of course.) – belacqua Jan 18 '11 at 02:01
1

You can ask to man to convert a manpage into HTML and then running a command to display it. So you can import a man page directly into calibre with (If you obtain something like command exited with status 3, install groff package):

man --html=calibre YOUR_MANPAGE

You can also import you manpage to calibre database without running GUI:

man --html='calibredb add' YOUR_MANPAGE

Once your manpage is in calibre, you can easily send them to your e-reader (I suggest to send them as .mobi format).

Now, just iterate over the list of manpage you want to import:

find /usr/share/man/man[1-9] -type f | xargs -l man --html='calibredb add'
1

all man pages are located at

/usr/share/man

But they're compressed in .gz files. Also there's a web where you can see all man pages online. I guess if you search a software who gives you the possibility to download all content of each page/link, you can create your own man-pages library for e reader