6

I was invited to re-post this question with less opinion, so if it seems familiar, that's why.

How can I convert info pages into man pages? I used to have a shell one liner that flattened an entire info document into a single flat page, suitable for navigating with less, but I seem to have lost it. Please share if you know how to do this. :)

Thanks!

mbac32768
  • 848
  • 1
  • 7
  • 13
  • 6
    Hah, I assume that you were requested to remove anti-info vitriol? If so, I share your feeling... – user5336 Mar 29 '10 at 14:50

4 Answers4

4

This will output an info as a flat text file:

info --subnodes --output=info_file.txt info_file

For example:

info --subnodes --output=info.txt info
less info.txt

One liner:

info --subnodes --output - info_file | less
Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
1

The script above does not quite work. For normal man pages, it gets into infinite recursion; not pleasant on the command line. When it invokes the "man" command it has to make sure it's not invoking itself -- this is an issue if it's in a directory that's in your PATH.

Since my ~/bin directory is in my PATH, I changed the end of the "case" list thus:

*)
  /usr/bin/man $@
  ;;
esac

I've never seen the real 'man' be anywhere but /usr/bin/man, so this should work.

4dummies
  • 111
  • 3
1

The other answers here will work, but I have a much simpler alternative:

info foo | less

This command take the output of info and pipe it through less, which will make the info page behave similar to a regular manpage. It's not as precise as the other alternatives, but will work in majority of cases.

Output:

stefanl@host:~ $ info vi | less

File: *manpages*,  Node: vim,  Up: (dir)

VIM(1)                                                                  VIM(1)

NAME
       vim - Vi IMproved, a programmers text editor

SYNOPSIS
       vim [options] [file ..]
       vim [options] -
       vim [options] -t tag
       vim [options] -q [errorfile]
...
...

A more precise, but more complicated, version would be:

info ls --subnodes -o - |less

The other answers here require that you remember arcane flags or make modification to your environment every single Linux system that you maintain, which doesn't work well if you have accounts on hundreds of systems. At some point, you're going to be on a system where your custom environment isn't present, and info foo | less will be very easy to remember.

Stefan Lasiewski
  • 22,949
  • 38
  • 129
  • 184
  • 1
    It works only if the info page is simple. It is not working if it contains subnodes. For instance try `info grub | less` . – Emmanuel Dec 09 '17 at 12:05
  • @Emmanuel "It works only if the info page is simple. It is not working if it contains subnodes. For instance try `info grub | less`". With texinfo v6.7 and less v581.2, I get an output of over 7000 lines, so I suppose that it works. What issue did you have? – kelvin Jun 30 '21 at 05:14
  • @kelvin I don't remember, I suppose it must have been an old version of texinfo. – Emmanuel Jul 07 '21 at 15:48
0

I didn't want to get out of the habit of typing 'man' so I ended up writing a wrapper using Dennis Williamson's answer.

Contents ~/bin/man:

#!/bin/bash

case $1 in
info-*)
  page=$(echo $1 | sed -e s/info-//g)
  tmpfile="/tmp/info2man-$page.txt"
  info --subnodes --output=$tmpfile $page \
  && less $tmpfile \
  && rm -f $tmpfile
  ;;
*)
  man $@
  ;;
esac

Use case

man sed

# learn the sed man page isn't adequate

man info-sed
mbac32768
  • 848
  • 1
  • 7
  • 13