* [gentoo-user] How to get plain ascii from "man"?
@ 2009-03-25 22:12 Grant Edwards
2009-03-25 22:21 ` [gentoo-user] " Grant Edwards
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Grant Edwards @ 2009-03-25 22:12 UTC (permalink / raw
To: gentoo-user
How do you get a plain ascii file (no backspacing, no escape
sequences) out of "man"? Running it through col or colcrt
doesn't work anymore, because the default output contains ANSI
color escape sequences.
grotty apparently outputs ANSI color escape sequences
regardless of whether or not the output is a tty and regardless
of the TERM setting.
Who decided that everyting in the friggin' world was an ANSI
color crt even if it's not a tty and TERM isn't set?
--
Grant Edwards grante Yow! Am I SHOPLIFTING?
at
visi.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gentoo-user] Re: How to get plain ascii from "man"?
2009-03-25 22:12 [gentoo-user] How to get plain ascii from "man"? Grant Edwards
@ 2009-03-25 22:21 ` Grant Edwards
2009-03-25 22:26 ` [gentoo-user] " Paul Hartman
2009-03-29 16:49 ` [gentoo-user] " Walter Dnes
2 siblings, 0 replies; 8+ messages in thread
From: Grant Edwards @ 2009-03-25 22:21 UTC (permalink / raw
To: gentoo-user
On 2009-03-25, Grant Edwards <grante@visi.com> wrote:
> How do you get a plain ascii file (no backspacing, no escape
> sequences) out of "man"?
I know I can always drop down 2 levels and do somthing like this:
bzcat /usr/share/man/bash.1.bz2 | troff -Tascii -mandoc | grotty -bcu >man.txt
But, I'm surprised that there's no "higher level" method like
the trusty old command that worked for at least 20 years:
man bash | col -b >man.txt
--
Grant Edwards grante Yow! A can of ASPARAGUS,
at 73 pigeons, some LIVE ammo,
visi.com and a FROZEN DAQUIRI!!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] How to get plain ascii from "man"?
2009-03-25 22:12 [gentoo-user] How to get plain ascii from "man"? Grant Edwards
2009-03-25 22:21 ` [gentoo-user] " Grant Edwards
@ 2009-03-25 22:26 ` Paul Hartman
2009-03-25 22:44 ` [gentoo-user] " Grant Edwards
2009-03-29 16:49 ` [gentoo-user] " Walter Dnes
2 siblings, 1 reply; 8+ messages in thread
From: Paul Hartman @ 2009-03-25 22:26 UTC (permalink / raw
To: gentoo-user
On Wed, Mar 25, 2009 at 5:12 PM, Grant Edwards <grante@visi.com> wrote:
> How do you get a plain ascii file (no backspacing, no escape
> sequences) out of "man"? Running it through col or colcrt
> doesn't work anymore, because the default output contains ANSI
> color escape sequences.
>
> grotty apparently outputs ANSI color escape sequences
> regardless of whether or not the output is a tty and regardless
> of the TERM setting.
>
> Who decided that everyting in the friggin' world was an ANSI
> color crt even if it's not a tty and TERM isn't set?
Edit /etc/man.conf and add -c to the commandline for TROFF, NROFF and
JNROFF. Then "man program | col -bf" or your method of choice should
work. There is a note in the man.conf comments about it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gentoo-user] Re: How to get plain ascii from "man"?
2009-03-25 22:26 ` [gentoo-user] " Paul Hartman
@ 2009-03-25 22:44 ` Grant Edwards
2009-03-25 23:01 ` Paul Hartman
2009-03-26 1:26 ` Grant Edwards
0 siblings, 2 replies; 8+ messages in thread
From: Grant Edwards @ 2009-03-25 22:44 UTC (permalink / raw
To: gentoo-user
On 2009-03-25, Paul Hartman <paul.hartman+gentoo@gmail.com> wrote:
> On Wed, Mar 25, 2009 at 5:12 PM, Grant Edwards <grante@visi.com> wrote:
>> How do you get a plain ascii file (no backspacing, no escape
>> sequences) out of "man"? Running it through col or colcrt
>> doesn't work anymore, because the default output contains ANSI
>> color escape sequences.
>>
>> grotty apparently outputs ANSI color escape sequences
>> regardless of whether or not the output is a tty and regardless
>> of the TERM setting.
>>
>> Who decided that everyting in the friggin' world was an ANSI
>> color crt even if it's not a tty and TERM isn't set?
>
> Edit /etc/man.conf and add -c to the commandline for TROFF,
> NROFF and JNROFF. Then "man program | col -bf" or your method
> of choice should work. There is a note in the man.conf
> comments about it.
That didn't work for me. Does it work for you?
I also tried manually running groff using the -c flag, and that
didn't work either.
[Actually, I didn't edit /etc/man.conf -- I copied it somewhere
else and edited that file, then pointed man to the modified
file using the -C option.]
--
Grant Edwards grante Yow! I would like to
at urinate in an OVULAR,
visi.com porcelain pool --
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Re: How to get plain ascii from "man"?
2009-03-25 22:44 ` [gentoo-user] " Grant Edwards
@ 2009-03-25 23:01 ` Paul Hartman
2009-03-26 1:26 ` Grant Edwards
1 sibling, 0 replies; 8+ messages in thread
From: Paul Hartman @ 2009-03-25 23:01 UTC (permalink / raw
To: gentoo-user
On Wed, Mar 25, 2009 at 5:44 PM, Grant Edwards <grante@visi.com> wrote:
> On 2009-03-25, Paul Hartman <paul.hartman+gentoo@gmail.com> wrote:
>> On Wed, Mar 25, 2009 at 5:12 PM, Grant Edwards <grante@visi.com> wrote:
>>> How do you get a plain ascii file (no backspacing, no escape
>>> sequences) out of "man"? Running it through col or colcrt
>>> doesn't work anymore, because the default output contains ANSI
>>> color escape sequences.
>>>
>>> grotty apparently outputs ANSI color escape sequences
>>> regardless of whether or not the output is a tty and regardless
>>> of the TERM setting.
>>>
>>> Who decided that everyting in the friggin' world was an ANSI
>>> color crt even if it's not a tty and TERM isn't set?
>>
>> Edit /etc/man.conf and add -c to the commandline for TROFF,
>> NROFF and JNROFF. Then "man program | col -bf" or your method
>> of choice should work. There is a note in the man.conf
>> comments about it.
>
> That didn't work for me. Does it work for you?
>
> I also tried manually running groff using the -c flag, and that
> didn't work either.
>
> [Actually, I didn't edit /etc/man.conf -- I copied it somewhere
> else and edited that file, then pointed man to the modified
> file using the -C option.]
Yes, it works for me. Without the -c option it put partial ANSI codes
all over, but with the -c added to man.conf piping it through col -bf
produces clean plain text output.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gentoo-user] Re: How to get plain ascii from "man"?
2009-03-25 22:44 ` [gentoo-user] " Grant Edwards
2009-03-25 23:01 ` Paul Hartman
@ 2009-03-26 1:26 ` Grant Edwards
1 sibling, 0 replies; 8+ messages in thread
From: Grant Edwards @ 2009-03-26 1:26 UTC (permalink / raw
To: gentoo-user
On 2009-03-25, Grant Edwards <grante@visi.com> wrote:
>> Edit /etc/man.conf and add -c to the commandline for TROFF,
>> NROFF and JNROFF. Then "man program | col -bf" or your method
>> of choice should work. There is a note in the man.conf
>> comments about it.
>
> That didn't work for me. Does it work for you?
Doh! I added the -c to the GROFF line not on the TROFF line.
> I also tried manually running groff using the -c flag, and that
> didn't work either.
The groff man page says that -c will be passed on to troff and
will disable color output, but that doesn't seem to work.
--
Grant
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] How to get plain ascii from "man"?
2009-03-25 22:12 [gentoo-user] How to get plain ascii from "man"? Grant Edwards
2009-03-25 22:21 ` [gentoo-user] " Grant Edwards
2009-03-25 22:26 ` [gentoo-user] " Paul Hartman
@ 2009-03-29 16:49 ` Walter Dnes
2009-03-29 17:14 ` [gentoo-user] " ABCD
2 siblings, 1 reply; 8+ messages in thread
From: Walter Dnes @ 2009-03-29 16:49 UTC (permalink / raw
To: gentoo-user
On Wed, Mar 25, 2009 at 10:12:20PM +0000, Grant Edwards wrote
> How do you get a plain ascii file (no backspacing, no escape
> sequences) out of "man"? Running it through col or colcrt
> doesn't work anymore, because the default output contains ANSI
> color escape sequences.
I done it! And no, the following "man2text" script is not brought to
you via an uncorrected dialup modem<g>.
#!/bin/bash
sed "s/^[\[[^m]\+m//g"
*IMPORTANT* the 8th and 9th columns of the second line are *NOT* "^[".
That's actually the <escape> character as displayed in vim. In vim in
entry mode, you can insert control character by prefixing them with
CTRL-V. To enter the <escape> character, press CTRL-V and release, then
press escape.
Here's the logic
- You want to get rid of all ANSI terminal sequences
- all ANSI terminal sequences start with <escape>[, have 1 or more
mode characters, and finish off with "m"
- the sed one-liner deletes all such occurences (technically, it
replaces them with nothing).
--
Walter Dnes <waltdnes@waltdnes.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gentoo-user] Re: How to get plain ascii from "man"?
2009-03-29 16:49 ` [gentoo-user] " Walter Dnes
@ 2009-03-29 17:14 ` ABCD
0 siblings, 0 replies; 8+ messages in thread
From: ABCD @ 2009-03-29 17:14 UTC (permalink / raw
To: gentoo-user
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Walter Dnes wrote:
> On Wed, Mar 25, 2009 at 10:12:20PM +0000, Grant Edwards wrote
>> How do you get a plain ascii file (no backspacing, no escape
>> sequences) out of "man"? Running it through col or colcrt
>> doesn't work anymore, because the default output contains ANSI
>> color escape sequences.
>
> I done it! And no, the following "man2text" script is not brought to
> you via an uncorrected dialup modem<g>.
>
> #!/bin/bash
> sed "s/^[\[[^m]\+m//g"
>
> *IMPORTANT* the 8th and 9th columns of the second line are *NOT* "^[".
> That's actually the <escape> character as displayed in vim. In vim in
> entry mode, you can insert control character by prefixing them with
> CTRL-V. To enter the <escape> character, press CTRL-V and release, then
> press escape.
>
> Here's the logic
> - You want to get rid of all ANSI terminal sequences
> - all ANSI terminal sequences start with <escape>[, have 1 or more
> mode characters, and finish off with "m"
> - the sed one-liner deletes all such occurences (technically, it
> replaces them with nothing).
>
Even better would be, as it avoids a call to bash:
#!/bin/sed -f
s/^[\[[^m]\+m//g
(with the same "^[" is really ESC)
- --
ABCD
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAknPrAoACgkQOypDUo0oQOrVYwCfZ/f8eaFpMy0E8+fs96qCG3Dv
mscAoLAdGesfNBz3EsRp7aaqUiBwjpeo
=qUzQ
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-03-29 17:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-25 22:12 [gentoo-user] How to get plain ascii from "man"? Grant Edwards
2009-03-25 22:21 ` [gentoo-user] " Grant Edwards
2009-03-25 22:26 ` [gentoo-user] " Paul Hartman
2009-03-25 22:44 ` [gentoo-user] " Grant Edwards
2009-03-25 23:01 ` Paul Hartman
2009-03-26 1:26 ` Grant Edwards
2009-03-29 16:49 ` [gentoo-user] " Walter Dnes
2009-03-29 17:14 ` [gentoo-user] " ABCD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox