Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
up vote 33 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.

share|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 '12 at 9:22
My watch is v0.3.0 and I'm on Ubuntu 10.0 – Paweł Gościcki Jan 19 '12 at 14:00
I've also version 0.3.0 and for simple "ls --color" the watch command will work but for some reason more complex scenarios do not: watch --color "sudo iwlist wlan0 scanning | egrep 'Quality|ESSID' | egrep --color -i 'foobar|$'"will eat the colors :( – math Mar 7 '12 at 13:39

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.

share|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

If you're using a Mac, like me, watch from Homebrew does not support colour.

What you want is fswatch but it's not Homebrew yet. To install it you'll want to do the slightly more convoluted‌​/Library/Formula/fswatch.rb

See this SO answer for usage.

share|improve this answer
This only works for the filesystem, while watch applies to a command – Brice Jan 7 '14 at 15:49
fswatch is available on Homebrew 0.9.5 – code_monk Oct 20 '14 at 1:45

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .