0

Is there a way to get the source out of the a preformatted man page? I need to parse the man page sources on different platforms and on one pc there are only cat pages, and I don't want to write 2 scripts for both situations.

Greets, Oliver

Trollhorn
  • 203
  • 3
  • 9

2 Answers2

1

You can't "generate" the *roff source from a formatted man page. However, you could simply write your script to work with the formatted version, and then run unformatted man pages through nroff. This way, you write one script instead of two and it works on all your target platforms.

larsks
  • 41,276
  • 13
  • 117
  • 170
  • Yeah, that sounds like a good solution... then I even don't have to deal with different source formats... thx! – Trollhorn Dec 14 '09 at 09:47
  • Hm, now I have the problem that the cat page is VERY difficult to parse due to escape sequences... should I strip them first? – Trollhorn Dec 15 '09 at 12:17
  • Probably, yes. Take a look at the "colcrt" command. Try, for example, "man ls | colcrt - | less". In fact, compare "man ls | less -RU" to "man ls | colcrt - | less -RU" to see exactly what's going on. – larsks Dec 15 '09 at 14:17
0

You should probably look at man man.

You can find the source file for a given man page with man --path command - so man --path man will give a result of /usr/share/man/en/man1/man.1.gz

fencepost
  • 972
  • 6
  • 10