Hi,
Does awk ever resolve params in the search pattern?..
The following awk doesnt know how to resolve ${tables[$j]}$ inside a loop.
k=`awk '/${tables[$j]}$/ ${graph[$i]}`
The search pattern has ${tables[$j]}$ and I am narrowing down my search with a $ at the end of string.
So...this leaves me with a question on if awk ever resolve the params in the search patterns?...I am sure it resolves in other places...like in this case ${graph[$i]}
Hi vgersh,
"${tables[$j]}" and "${graph[$i]}" are 2 arrays holding 2 distinct sets of elements like table list and graph list.
A simplified code snippet giving a better idea...
#! /bin/ksh
count1=`ls -lart P*.ksh | awk '{print $9}' | wc -l`
list1="`ls -lart P*.ksh | awk '{print $9}'`"
set -A graph $list1
count2=`wc -l read_table.dat | awk '{print $1}'`
list2="`cat read_table.dat`"
set -A tables $list2
j=0
while ((j<$count2))
do
i=0
while ((i<$count1))
do
k=`awk '/ETL_VW_SCHEMA/ && /[.]${tables[$j]}$/ || /EDW_DB_SCHEMA/ && /[.]${tables[$j]}$/' ${graph[$i]}`
((i=i+1))
done
((j=j+1))
done
Awk in the inner most loop doesnt resolve ${tables[$j]} during the run time....but no issues with ${graph[$i]}.
Hope this gives a better idea on the problem...
Hi Johnson/Vgersh,
Thank you very much for the suggestions and the pointers..
But my shell errors out with the awk syntax....here are some quick details on my OS and the actual error itself...I tried switching my shell to ksh and run it but still errors out the same way as mentioned below.
$ awk -v t="B1_STAT_HIST" '/ETL_VW_SCHEMA/ && $0 ~ ("[.]" t "$") || /EDW_DB_SCHEMA/ && $0 ~ ("[.]" t "$")' PDEWG300_B1_STAT_HIST.ksh
awk: syntax error near line 1
awk: bailing out near line 1
$ uname -a
SunOS xspetl01 5.8 Generic_117350-36 sun4u sparc SUNW,Sun-Fire-480R
k=`nawk -v t="${tables[$j]}" '/ETL_VW_SCHEMA/ && $0 ~ ("[.]" t "$") / || /EDW_DB_SCHEMA/ && $0 ~ ("[.]" t "$")' ${graph[$i]}`
Few of my table occurences(${tables[$j]}) are in lower case and this script doesn't quite catch them....and I need the command to take care of lower cases too with the present functionality.
I could have researched on this, but due to time crunch not able to...
Thx !
Hi Johnson,
I am using an array({tables[$j]}) to store all the table names, which means I dont have the luxury of using the exact patterns like [Ee][Tt][Ll].
There are around 200 tables in the list...
So, Is there a way I can direct the shell to convert the lower cased table names to uppercase as soon as it parses and apply the awk command ?.....
This will not work in my case as my table list is always in upper case and 90% of the pattern occurences in the search file will be in upper case but there are few cases(which are unknown) where the occurences will be in lower case and we need to address such instances....I guess we need to write up a condition inside awk to check for the case.