From man watch:

Non-printing characters are stripped from program output. Use "cat -v" as part of the command pipeline if you want to see them.

So how do I use cat -v if I want to see the colored output from:

watch ls -al --color
link|improve this question

feedback

3 Answers

up vote 4 down vote accepted

The right command is

watch --color "ls -a1 --color"

It isn't documented in the man page or the --help screen. I has to use strings to find it.

link|improve this answer
This works! Although it's worth noting, that the --color option has been added quite recently to watch. – Paweł Gościcki Mar 6 '11 at 7:58
Not in Fedora 15 it doesn't! :( watch: unrecognized option '--color' – Andy Lee Robinson Sep 30 '11 at 21:56
@PawełGościcki What operating system are you using? I can't find anything about a --color option being added to watch. – Ikke Jan 19 at 9:22
@PawełGościcki Nevermind, already found it on gitorious, although, couldn't get it to work with phpunit. – Ikke Jan 19 at 13:11
My watch is v0.3.0 and I'm on Ubuntu 10.0 – Paweł Gościcki Jan 19 at 14:00
show 2 more comments
feedback

I think it may not be possible with the 'watch' command. Here is a longer way of doing it:

while true; do clear; date;echo;ls -al --color; sleep 2; done

You could put this in a script, for example:

echo "while true; do clear; date;echo;\$*;sleep 2; done" > watch2
chmod +x watch2
./watch2 ls -al --color

To clarify, here's why I think it's not possible with the 'watch' command. See what happens if you use cat -v:

watch "ls -al --color|cat -v"

It shows you the color control characters...which I think is not what you want.

link|improve this answer
man watch clearly suggests that it should be possible without dissing watch. – Paweł Gościcki Mar 29 '10 at 19:27
It doesn't say you will be able to see colors. It says you will be able to see the non-printable characters. Try my command as above with cat -v to see what man watch was talking about. – davr Mar 29 '10 at 20:03
OK. It seems I must accept the fact that it's simply impossible. – Paweł Gościcki Mar 31 '10 at 15:37
feedback

watch doesn't work with color output and I know of no way to make it do it. You can create your own script to emulate it, though.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.