Need help urgently

Hi to All,

I m a regular visitor of this site but this one is my first thread .
Although I ve tried but I cant find the solution .:confused:

I ve number of files having extension .file., which having some define statement in it.The files consits as follows
Ex:-
abc.file
`define ADCONV0 TB_DIGRFAFE.digrf0.udigrf_top.uad0_wrap
`define APLL TB_DIGRFAFE.digrf0.udigrf_top.uapl_wrap
`define DPLL TB_DIGRFAFE.digrf0.udigrf_top.udpl_wrap

bcd.file

`define APLL TB_DIGRFAFE.digrf0.udigrf_top.uapl_wrap
`define DPLL TB_DIGRFAFE.digrf0.udigrf_top.udpl_wrap
`define DACONV0 TB_DIGRFAFE.digrf0.udigrf_top.uda0_wrap
`define TOP TB_DIGRFAFE.digrf0
`define SCI TB_DIGRFAFE.digrf0.udigrf_top.usci_wrap

output should be
Path of FILE ./abc.file
same
same
same

Path of FILE ./bcd.file
same
same
same
`define TOP TB_DIGRFAFE.digrf0
`define SCI TB_DIGRFAFE.digrf0.udigrf_top.usci_wrap

The last two lines output because they are not defined inside my
shell script...
My program is like below

#!/bin/sh
for temp in `find . -name '*.file'`# Temp stores all the .file extension
do
echo "Path of FILE $temp"

nawk '\
BEGIN{

#lookup table defination

  ref_arr["ADCONV0"] = "TB\_DIGRFAFE.digrf0.udigrf\_top.uad0_wrap"
  ref_arr["APLL"]    = "TB\_DIGRFAFE.digrf0.udigrf\_top.uapl_wrap"
  ref_arr["DPLL"]    = "TB\_DIGRFAFE.digrf0.udigrf\_top.udpl_wrap"
  ref_arr["DACONV0"] = "TB\_DIGRFAFE.digrf0.udigrf\_top.uda0_wrap"

}

/^\`define/ \{
         str = $2
         val = $3
        for\(item in ref_arr\)\{
             if\( str == item\)\{
               if \(ref_arr[str] == val\)
                   print "same"
                else
                    print $0
           \}
        \}
\} ' $temp

done

Now I m getting output as follows
Path of FILE ./x.file
same
same
same
Path of FILE ./y.file
same
same
same
Path of FILE ./abc.file
same
`define DACONV0 cat.grep.cut

I know there are some logical mistakes in my for loop but I m not able to catch it.
-------------------------------------------------------------------------

Please pls pls help.........
Prady

If you could give us a sample of what you want your code to produce from the input you give it I think it would be easier for someone (not necessarily me I hasten to add) to help you out.

Thanks for your reply ajcannon.Yes it seems to simple but I m screwed.

Input files (.files)
abc.file
`define ADCONV0 TB_DIGRFAFE.digrf0.udigrf_top.uad0_wrap
`define APLL TB_DIGRFAFE.digrf0.udigrf_top.uapl_wrap
`define DPLL TB_DIGRFAFE.digrf0.udigrf_top.udpl_wrap

bcd.file
`define APLL TB_DIGRFAFE.digrf0.udigrf_top.uapl_wrap
`define DPLL TB_DIGRFAFE.digrf0.udigrf_top.udpl_wrap
`define DACONV0 TB_DIGRFAFE.digrf0.udigrf_top.uda0_wrap
`define TOP TB_DIGRFAFE.digrf0
`define SCI TB_DIGRFAFE.digrf0.udigrf_top.usci_wrap

x.file
`define DPLL TB_DIGRFAFE.digrf0.udigrf_top.udpl_wrap
`define DACONV0 cat.grep.cut

OBJECTIVE

Path of FILE ./abc.file
same
same
same

Path of FILE ./bcd.file
same
same
same
`define TOP TB_DIGRFAFE.digrf0
`define SCI TB_DIGRFAFE.digrf0.udigrf_top.usci_wrap

Path of FILE ./x.file
`define DACONV0 cat.grep.cut

The output of abc.file is of three lines written as "same" as all the 3 lines matched which are defined in my lookup table/hash table in my shell script.

The last 2 statements in the output of ./bcd.file because they are not defined inside my look up table in my shell script.

and same for ./x.file . The first line matches but the second line does not match so it prints the whole line.

Thanks all I got the solution.It is as follows

#!/bin/sh

for temp in `find . -name '*.file'`
do
echo "Path of FILE $temp"

nawk '\
BEGIN{
ref_arr["ADCONV0"] = "TB_DIGRFAFE.digrf0.udigrf_top.uad0_wrap"
ref_arr["APLL"] = "TB_DIGRFAFE.digrf0.udigrf_top.uapl_wrap"
ref_arr["DPLL"] = "TB_DIGRFAFE.digrf0.udigrf_top.udpl_wrap"
ref_arr["DACONV0"] = "TB_DIGRFAFE.digrf0.udigrf_top.uda0_wrap"
}

/^[ \\t]*\`define/ \{
         str = $2
         val = $3
     flag = 0
        for\(item in ref_arr\)\{
           if\( str == item\)\{
               if \(ref_arr[$2] == val\)\{
                   print "same"
	       flag = 1
           \}    
           \}
        \}
    if\(flag == 0\)\{
	       print $0
       \}	       

# print ( "*********"$2 " " $3 )
} ' $temp
done