D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] colour in bash print/echo statements?



On Tuesday 29 June 2004 4:36, Grant Sewell wrote:
On Tue, 29 Jun 2004 13:19:05 +0100

Neil Williams <linux@xxxxxxxxxxxxxx> wrote:
Sorry, I should have been clearer - it isn't in a log file, it's coming
to the screen direct. It's a script that looks for bad servers, so it
hangs a lot. I can't output to a log file because I'd never know when
it's hung.

Well, if you have the script in front of you, you could edit the
appropriate sections and change their output lines to include colouring
codes.  
echo -e '\033[1;33mHello World\033[0m'

In Perl, it works via the system call, thanks:
#!/usr/bin/perl
$var = "test line";
$init = "echo '\033[1;33m";
$endit = "\033[0m'";
system("echo '\033[1;33m$var\033[0m'");
system("$init$var$endit");


Hope this helps.
Thanks.

-- 

Neil Williams
=============
http://www.codehelp.co.uk/
http://www.dclug.org.uk/
http://www.isbn.org.uk/
http://sourceforge.net/projects/isbnsearch/

http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3

Attachment: pgp00028.pgp
Description: signature


Lynx friendly