Is there any way to export the colors of an output of a command?
Let's explain it with a small example:
ls -alh --color=auto
will print the colored contents of the directory, while
ls -alh --color=auto | cat
won't print some color. What I want to know is a trick or a tool, let's call it magic, that restores these commands like \033[1m, so that colors are available for latter processing:
ls -alh --color=auto | magic | cat
or
ls -alh --color=auto | magic >> file
Update:
I'm using ls just for this example, but want to know whether there is a general possibility.
script outputfile command
will do the trick. e.g:
script capture.txt ls --color=always
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With