Re: extracting with sed

From: Tom Lanyon <>
Date: Sat, 6 Feb 2010 22:03:23 +1030
Message-Id: <>

On 06/02/2010, at 3:30 AM, Bobak, Mark wrote:

> Well, since no one else has answered yet, Iíll show you my (really ugly) solution:
> [oracle_at_msrac201 ~]$ cat log.txt
> SP2-0310: unable to open file ".[FALSE]"
> SQL> spool off
> [oracle_at_msrac201 ~]$ cat log.txt|tail -2|head -1|awk -F[ '{ print$2 }'|awk -F] '{ print $1}'
> Yeah, Iím no awk or sed genius. I use tail and head to get only the second line, then I need to use awk twice to parse out around each of the Ď[Ď and Ď]í. Yes, Iím sure thereís a better and cleaner way.

How about just awk?

        awk -F '[\\[\\]]' '/^SP2-/ {print $2}' log.txt

Look for any lines starting with SP2-, split based on '[' or ']' as a field delimiter and print the second field.

Tom-- Received on Sat Feb 06 2010 - 05:33:23 CST

Original text of this message