Re: Colors/bold chars in a select? - Mailing list pgsql-novice

From Andrew Chambers
Subject Re: Colors/bold chars in a select?
Date
Msg-id 20060415123147.GB12186@yapgi.hopto.org
Whole thread Raw
In response to Re: Colors/bold chars in a select?  (Ennio-Sr <nasr.laili@tin.it>)
Responses Re: Colors/bold chars in a select?
List pgsql-novice
* Ennio-Sr <nasr.laili@tin.it> [2006-04-14 23:27:38 +0200]:

> I'm using bash scripts which call psql commands (working in console, not
> xterm); so, I suppose I'd have to first save the query result in a
> temporary table/file and then run the loop on this table/file (no idea
> for the time being on how to do that ...).
> I've heard about php potential, but my learning curve would be too long;
> the same applies to html and css (this is a programming tool, I suppose?).

So the output is coming to the terminal?  There are control codes you
can use to make text bold/colored on the terminal.  For example...

echo -e "\e[32;01mGreen Hello"

should print out "Green Hello" in green text.  You can probably find more
examples in the scripts that your distribution uses to start various
deamon processes (usually in /etc/init.d).

This task sounds like a job for awk.  The syntax of the script below
might not be quite correct but you should be able to do something
like...

psql -f query.sql |awk ' { if($2 >= $1) print "\e[32;01m" $0
                           else print $0
                         } '

Hope this helps,
Andy Chambers

Send instant messages to your online friends http://uk.messenger.yahoo.com

pgsql-novice by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Crontab problem with backup
Next
From: Frank Bax
Date:
Subject: Re: Crontab problem with backup