I'm altering scripts at work that monitor log files to single out certain items and colorize them. The final output is a list of 6-digit numbers in several columns. I've been able to add a ~ to the start of the number, and it doesn't break anything in the final output, but it's rather ugly and hard to read. However, when I try to colorize the number, either in preceding bash scripts or the final processing of the data in a perl script, the color text gets clobbered.
For example, the original number, which I will put into $num:
123456
I input this in perl (or, much the same thing in bash):
"\e[1;34m" . $num . "\e[0m"
And here's what I get:
[1;34m123456[0m
I've also tried this, an escaped version, but get the same thing:
"\x1B[1;34m" . $num . "\x1B[0m"
If this makes a difference, here's the real stack of scripts (it's a mess):
- Perl called inside shell script, which then pipes to
grep/cut/etc. - shell script with more
cut/etc., then pipes to .pl - shell script watches that output
Maybe watch doesn't like color then?
I don't know perl too well, so I guess it wouldn't hurt to show what I'm seeing around the print lines:
my $format = ("%-8s") x scalar(@{$a[0]});
printf("$format\n", @$_)