You are not logged in.
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
I found the sed command here: http://serverfault.com/questions/71285/ … -text-file
hth
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
Your link provides a relevant inquery.
You can't, because what is an escape sequence isn't well-defined in general -- you need to know what sort of terminal your escape sequences are designed for. If you want to restrict the problem to "strip ANSI colour sequences" (a fairly likely assumption), something like:
I generally recommend learning more about sed and regular expression. It made my life easier so many times, but also harder, because regexp is so sensitive to mistakes.
I'm so meta, even this acronym
Offline
^ OK, that is a valid proviso.
So, in the future, I will first try this command and then, if it does not do what I intended it to do, I will look into the sed expression.
I must admit that, not being exactly a dilettante, I do not think I would have come up with the provided solution.
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat