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

link|improve this question

71% accept rate
feedback

2 Answers

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.

link|improve this answer
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 9: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
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.