Code:
$ man cat Code:
% echo -en '\r' | cat | xxd |
This works for me:
Code:
ls --color=always > file This link, even though it's mainly to explain how to color your prompt, has a lot of info about the escape codes: https://wiki.archlinux.org/index.php/Color_Bash_Prompt |
Quote:
Code:
$ mkdir dir Code:
$ ls -d --color dir |cat -v >testfile.txt |
I didn't know about the uniname command from the uniutils package. Thank you David for revealing it. Regarding the weird behaviors, I think they have been clarified. Thanks to all.
|
Very interesting stuff, but not the answer I was looking for. I want to know if the colors can be saved into a file so that the file can be printed showing different file types in different colors. Anyway thanks for the answers.
|
Quote:
The correct way to write the file can be either one of the following (as shown before): Code:
\ls --color > file |
smurthygr wants it printed out on paper as it's seen in the terminal.
|
Quote:
Unfortunately, I'm not aware of any tool to interpret ansi color escape sequences and convert them to Postscript colors (it looks like enscript and a2ps, just to mention some CLI printing tools, cannot do that). |
I was going to post a nice example of how the $TERM variable can be used to modify the escape codes used by ls to generate the color output, so the OP could potentially control how the listing gets created, and then also potentially create a filter that can translate the output to something his printer can handle. However, when I set $TERM to any value that is found as a terminal type entry in /etc/termcap, 'ls --color=always' doesn't change the escape sequences that it uses to generate color output.
So, does anyone know how to control what ls uses to generate its escape codes? My testing is done on a KDE Konsole ($TERM=xterm). Code:
#! /bin/sh Sorry if this is a hijacking of the thread. It started out as an on-topic contribution... --- rod. |
Quote:
On the other hand, ls is influenced by the LS_COLORS environment variable, but only to retrieve the color definitions associated to each object and change colors accordingly. |
Quote:
Here's a detailed how to: http://ubuntuforums.org/archive/index.php/t-41538.html also check out man dircolors and info dircolors. |
Yes, I knew that. That simply defines the relationship between file types and colors. How the colors actually get displayed on a terminal is a different matter, and is quite device-dependent. That is the part that I was trying to establish. colucix seems to have figured that part out. Now that I know where there must exist a concise list of the escape codes used, I think I will have a go at producing a basic filter that can translate the escape codes to something palatable to a printer. I don't know that Postscript is the easiest to generate, so perhaps some intermediate format, letting an existing tool do some of the heavy lifting. While researching the subject, I came across some PHP code that does the translation to some kind of HTML. Perl should do at least as well.
--- rod. |
@ ntubski,
I'm curious: on your system, what package brings `xxd` ? |
To my surprise it turns out to be vim-common: Debian Package Search for xxd.
|
Ehh, no wonder I couldn't find it - I haven't got vim installed.
Thanks! |
All times are GMT -5. The time now is 10:44 PM. |