2

I am running

watch tail -n 15     20151217.log

and my output looks like

12-17 04:42:52 DEBUG [31mXYZT    10  91.5[0m

Instead, I want to see it as colored text. What can I do?

I don't want to use simply tail -n, because it somehow skips lines and stalls.

Any ideas?

1
  • Also relevant: Many programs disable coloring (--color=auto or similar) when they detect output is being redirected.
    – Daniel B
    Dec 17, 2015 at 22:23

1 Answer 1

1

The manual page for watch lists this option:

   -c, --color
          Interpret ANSI color and style sequences.

So you could change your command to

watch -c tail -n 15     20151217.log

and see the color as intended.

In preparing answer, I tested with Debian 7, which uses procps-ng. Scientific Linux uses an older version of procps (the set of programs containing watch). Debian uses the newer version cited in the manual page. For reference, Scientific Linux 6 uses the "latest" version from the SourceForge project which was forked several years ago here. The history for watch.c and watch.1 show that the color option was added in 2011 in procps-ng.

The older version from procps has no ability to filter escape sequences.

1
  • I have scientific linux. watch --c tail -n 15 20151218.log watch: unrecognized option '--c' Usage: watch [-dhntv] [--differences[=cumulative]] [--help] [--interval=<n>] [--no-title] [--version] <command>
    – The Baron
    Dec 18, 2015 at 14:54

You must log in to answer this question.

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