Répondre au commentaire

Remove bold and underline attributes (overstrike) from a text or a manpage

Under Unix/Linux, commands like « man » output texts containing bold and underline attributes, even in console mode. These attributes are produced by inserting a combination of control characters (« Backspace » or « ^H ») and underscores (« _ ») after the characters to highlight.

Sometimes you need to remove these overstrike control characters.

To do this, you can use the following command line:

  1. sed -e 's/_^H//g' -e 's/^H.//g' -e 's/^[\[[0-9]*m//g' < infile.txt > outfile.txt

Or under Vim type the two following commands:

  1. :%s/_^H//g
  2. :%s/^H.//g
  3. :%s/^[\[[0-9]*m//g'

And it's done!

Beware : In order to type the ^H control char on the command line prepend it with your shell's escape character, for example « Control-V + Control-H » under Zsh and Vim.

Répondre

Le contenu de ce champ ne sera pas montré publiquement.