9

I'd like to read unix manpages on my kindle. I know I can just redirect the man output to a file and give it a .txt extension. But is there a convenient way to convert them en masse to a format with proper cross-references?

Edit: An apology for my behavior in this question. I told pat that I would accept the comment if submitted as an answer, and then better answers came and I did not keep my promise (Sorry). I enthusiastically accepted Caleb's answer that produces html versions of the manpages; and then some time later when I actually tried transferring the files to the kindle, I discovered that the kindle would not display html files; and I switched acceptance without explanation (Sorry). The kindle appears to require .txt or .pdf (or one of the various real eBook formats). I hope I have explained myself.

Also, I didn't have a realistic understanding of how many, many manpages there are with a Debian Linux distribution, and so Caleb's comment about selecting a "Best Of" collection appears to be the best idea. But I don't really have the inclination to try to do this myself (which is a prerequisite for asking questions on StackExchange sites), so I'm not comfortable asking how to select the "Best Of", even though it really is necessary practically in order to do this.

1

2 Answers 2

7

To dump all the sections of all the man pages on your system to html you could try something like this from a blank directory:

IFS=\.
find /usr/share/man/man* -type f -exec basename {} .gz \; |
    while read page section; do
        man -Thtml $section $page > $page.$section.html
    done
2
  • Gee, it sure takes a while, don't it? :) Dec 30, 2011 at 7:51
  • 1
    @luserdroog: Yes indeed it does. You're the one that asked to convert every unix man page on your system en masse! If what you really want is a "best of" collection to browse in your spare time, a different approach is probably in order.
    – Caleb
    Jan 2, 2012 at 13:45
2

To convert every man page to pdf I did man -k . > temp. I created a temp file and a script named file.sh:

#! /bin/bash
if [ $# -eq 1 ] ; then
    to_pdf=$(which ps2pdf)
    if [ -z "$to_pdf" ] ; then
    to_pdf=$(which pstopdf)
    fi
    name="$1"
    case "$to_pdf"  in
        *pstopdf) man -t "$name" | "$to_pdf" -i -o "$fname.pdf" ;;
        *ps2pdf)  man -t "$name" | "$to_pdf" - "$name.pdf" ;;
        *)        man -t "$name" > "$fname.ps"
    esac
    exit $?
fi
echo "Wrong number of parameters"
exit 1

I wrote a python file pythonfile.py

import os
f=open("temp","r")
for i in f:
    c="bash file.sh "+str(i)
    os.system(c)`

Then I did

python pythonfile.py 

This will create a pdf for every man page separately inside your working directory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .