For Programmers: Free Programming Magazines  


Home > Archive > AWK > September 2006 > looking for pattern in big file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author looking for pattern in big file
mtfuri@fibimail.co.il

2006-09-11, 6:56 pm

Hi all,
I lost my O'reilly book and wonder if someone can tell me how to use
awk in order to retrieve
oracle colunm names from a big file.

file has text like
select xxxxxx.aaaa, xxxxxx.bbbbbb, yyyyyy.ccccc from ... where (
xxxxxx.aaaaa
and xxxxxxx.bbbbbbb) ........
and there are very many lines like this.
I would like to print out all the colunm names which come after xxxxxx.

I tried to use index command but I got lost while looping toward the
end of the line..
TIA
Uri

Janis Papanagnou

2006-09-11, 6:56 pm

mtfuri@fibimail.co.il wrote:
> Hi all,
> I lost my O'reilly book and wonder if someone can tell me how to use
> awk in order to retrieve
> oracle colunm names from a big file.
>
> file has text like
> select xxxxxx.aaaa, xxxxxx.bbbbbb, yyyyyy.ccccc from ... where (
> xxxxxx.aaaaa
> and xxxxxxx.bbbbbbb) ........
> and there are very many lines like this.
> I would like to print out all the colunm names which come after xxxxxx.


In what format? Unique names or with duplicates? Start with this...

BEGIN { str="xxxxxx" ; pos=length(str)+2 }
$1 == "select" {
for (f=2; f<=NF; f++)
if ((i=index($f,str))==1)
printf("%s ", substr($f,pos))
print ""
}


Janis

>
> I tried to use index command but I got lost while looping toward the
> end of the line..
> TIA
> Uri
>

mtfuri@fibimail.co.il

2006-09-12, 3:56 am

Hi Janis ,
This looks just great thank you for saving my time and nurves !!

Uri

Janis Papanagnou wrote:[color=darkred]
> mtfuri@fibimail.co.il wrote:
>
> In what format? Unique names or with duplicates? Start with this...
>
> BEGIN { str="xxxxxx" ; pos=length(str)+2 }
> $1 == "select" {
> for (f=2; f<=NF; f++)
> if ((i=index($f,str))==1)
> printf("%s ", substr($f,pos))
> print ""
> }
>
>
> Janis
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com