Redirect colored output to file
Since the colours are stored with their ansi sequence you can create a script to translate each of them... or you can use a script just made.
For example it exists the script ansi2html [v0.15,v0.23] that you can make executable, put in a directory of your path (typically ~/bin
)
and use with
command | ansi2html.sh > file.html
Then if you need a different format you can convert it or you can rewrite the script.
Note that some commands know if their output is piped or not.
For example, ls
may change its output if piped.