Gentoo Archives: gentoo-user

From: Walter Dnes <waltdnes@××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] How to get plain ascii from "man"?
Date: Sun, 29 Mar 2009 16:49:51
In Reply to: [gentoo-user] How to get plain ascii from "man"? by Grant Edwards
1 On Wed, Mar 25, 2009 at 10:12:20PM +0000, Grant Edwards wrote
2 > How do you get a plain ascii file (no backspacing, no escape
3 > sequences) out of "man"? Running it through col or colcrt
4 > doesn't work anymore, because the default output contains ANSI
5 > color escape sequences.
7 I done it! And no, the following "man2text" script is not brought to
8 you via an uncorrected dialup modem<g>.
10 #!/bin/bash
11 sed "s/^[\[[^m]\+m//g"
13 *IMPORTANT* the 8th and 9th columns of the second line are *NOT* "^[".
14 That's actually the <escape> character as displayed in vim. In vim in
15 entry mode, you can insert control character by prefixing them with
16 CTRL-V. To enter the <escape> character, press CTRL-V and release, then
17 press escape.
19 Here's the logic
20 - You want to get rid of all ANSI terminal sequences
21 - all ANSI terminal sequences start with <escape>[, have 1 or more
22 mode characters, and finish off with "m"
23 - the sed one-liner deletes all such occurences (technically, it
24 replaces them with nothing).
26 --
27 Walter Dnes <waltdnes@××××××××.org>


Subject Author
[gentoo-user] Re: How to get plain ascii from "man"? ABCD <en.ABCD@×××××.com>