PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : man-pages in reines ascii umwandeln ???



Matzetronic
30.06.02, 13:42
hallo,

ich bin gerade dabei, mir eine bzw. mehrere CD's mit Büchern, Howto's, Doc's etc. zusammenzustellen. ich würde auch gern einige der wichtigsten Man-Pages mit draufpacken. mein problem ist leider, dass ich nicht weiss, wie ich dieses format in reines ASCII-Format bekomme - ohne diese dämlichen Steuerzeichen. mein einfach gedachter ansatz "man test > test_man.txt" klappt nicht, da immer noch irgendwelche Steuerzeichen enthalten sind :mad:

meine frage: wie kriege ich man - pages in ein reines textformat ???
ich verzweifle hier....

matze

:ugly:

keiner_1
30.06.02, 13:55
Sali

da fält mir auch nichts ein. Ich kenne nur man2html, das sollte doch auch gehen?

greetz
adme

ReSeT
30.06.02, 14:20
How do I get a plain text man page without all that ^H^_ stuff?

Have a look at col(1), because col can filter out backspace sequences. Just in case you can't wait that long:

funnyprompt$ groff -t -e -mandoc -Tascii manpage.1 | col -bx > manpage.txt

The -t and -e switches tell groff to preprocess using tbl and eqn. This is overkill for man pages that don't require preprocessing but it does no harm apart from a few CPU cycles wasted. On the other hand, not using -t when it is actually required does harm: the table is terribly formatted. You can even find out (well, "guess" is a better word) what command is needed to format a certain groff document (not just man pages) by issuing

funnyprompt$ grog /usr/man/man7/signal.7
groff -t -man /usr/man/man7/signal.7

"Grog" stands for "GROff Guess", and it does what it says--guess. If it were perfect we wouldn't need options any more. I've seen it guess incorrectly on macro packages and on preprocessors. Here is a little perl script I wrote that can delete the page headers and footers, thereby saving you a few pages (and mother nature a tree) when printing long and elaborate man pages. Save it in a file named strip-headers & chmod 755.

#!/usr/bin/perl -wn
# make it slurp the whole file at once:
undef $/;
# delete first header:
s/^\n*.*\n+//;
# delete last footer:
s/\n+.*\n+$/\n/g;
# delete page breaks:
s/\n\n+[^ \t].*\n\n+(\S+).*\1\n\n+/\n/g;
# collapse two or more blank lines into a single one:
s/\n{3,}/\n\n/g;
# see what's left...
print;

You have to use it as the first filter after the man command as it relies on the number of newlines being output by groff. For example:

funnyprompt$ man bash | strip-headers | col -bx > bash.txt



Hab ich übrigens mit
http://www.google.de/search?q=%2Blinux+%2Bman+%2Bpages+%2Bascii&ie=UTF-8&oe=UTF8&hl=de&btnG=Google-Suche&meta=

ergoogelt

:D

GreetZ

ReSeT

melody lee
30.06.02, 15:17
man programm | col -b > manpage.txt

fs111
30.06.02, 16:24
Das ist doch ganz einfach: man irgendwas > eineDatei.txt und fertig. Wo liegt denn da jetzt genau das Problem? HAbe ich da was missverstanden?

fs111

Matzetronic
30.06.02, 17:57
danke euch !!! :)

hab aber mittlerweile schon eine möglichkeit gefunden. ist zwar kompliziert, aber mit script ist es egal. ich wandle erst in html mit

rman -f html manpage manpage.html
und dann mit
lynx -dump manpage.html manpage.txt

ins textformat.

matze

fs111
30.06.02, 18:21
Was ist denn an meiner (einfachen Lösung) nicht OK?

keiner_1
30.06.02, 19:44
Was ist denn an meiner (einfachen Lösung) nicht OK?

die Formatierung: mach die Datei mal mit dem vi auf und du wirst es sofort feststellen

greetz
adme

fs111
01.07.02, 07:48
Stimmt, aber wenn ich mir die Datei mit more/less ansehe, ist sie wie das Original. Komisch, oder?

fs111