sed or awk help needed

hi all,

tnsping DBNAME > out.txt

cat out.txt
TNS Ping Utility for Linux: Version 10.2.0.2.0 - Production on 23-JUL-2009 05:49:52
Copyright (c) 1997, 2005, Oracle. All rights reserved.
Used parameter files:
/fisc/oracle/product/10.2.0/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL= TCP)(HOST= Hostname)(Port= 1521)) (CONNECT_DATA = (SID = DBNAME)))
OK (0 msec)

Now i will grep for "OK" if it is true then i want to print "<font color=green>" or else print "<font color=red>".

How to do it in awk or sed, pls advice me.

You can do something like that (without sed or awk):

grep -q '^OK' out.txt && echo '<font color=green>' || echo '<font color=red>'

Jean-Pierre

its working as expected thanks very much Jean-Pierre!!!