The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
CC Solution Required Urgently satty UNIX for Dummies Questions & Answers 5 05-29-2008 07:04 AM
help needed urgently nabmufti Shell Programming and Scripting 11 02-11-2008 07:17 AM
Setting Up Profile.......Need Help Urgently reachtokhan UNIX for Advanced & Expert Users 13 11-06-2007 02:06 PM
Need Information Urgently. sumit_krishan UNIX for Dummies Questions & Answers 3 06-08-2005 06:13 AM
link and unlink , urgently... umonk UNIX for Advanced & Expert Users 1 12-17-2001 11:06 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-03-2007
Registered User
 

Join Date: Sep 2007
Posts: 163
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 .

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

Last edited by user_prady; 09-03-2007 at 09:36 PM..
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-03-2007
Registered User
 

Join Date: Aug 2007
Location: Binfield, Berkshire. UK
Posts: 91
Please tell us what it is you are trying to achieve

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.
Reply With Quote
  #3 (permalink)  
Old 09-03-2007
Registered User
 

Join Date: Sep 2007
Posts: 163
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.

Last edited by user_prady; 09-03-2007 at 09:21 PM..
Reply With Quote
  #4 (permalink)  
Old 09-03-2007
Registered User
 

Join Date: Sep 2007
Posts: 163
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Bookmarks

Tags
None

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:




All times are GMT -4. The time now is 09:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66