jueves, marzo 15, 2012

Remover secuencias de escape de terminal usando un comando

How to remove ANSI escape sequences from a text file: e.g. remove escape sequences from the output of 'script':
I needed this functionality just now and I thought 'Why not share it?'. So, here it is:
Add to your $HOME/.bashrc
alias stresc='sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"'
You may replace 'stresc' by whatever you prefer, just make sure it is not an already existing command or alias.
This effectively creates your own personal 'strip escape' command.
To use it in a terminal
stresc filename
or
stresc filename > other-file-name

fuente: http://crunchbanglinux.org/forums/topic/15321/how-to-remove-ansi-escape-sequences-from-a-text-file/

No hay comentarios.: