AWK script problem insertion of code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting AWK script problem insertion of code
# 1  
Old 03-11-2011
AWK script problem insertion of code

Hi ,

I am having two files like this

Code:
 
FILE1 
####################
 
input SI_TESTONLY_R_00;
input CE0_SE_INPUT_TESTONLY;
input CE0_TCLK_TESTONLY;
input SI_JTGCLOCKDR_JTAG_R_00;
input CE0_TCLK_JTGCLOCKDR_JTAG;
input CE0_SE_INPUT_JTGCLOCKDR_JTAG;
output SO_TESTONLY_R_00;
output SO_JTGCLOCKDR_JTAG_R_00;

#######################

FILE2
Code:
 
#########################
 
SDFFQ_X1M_A9TH P1_sdflop (
.CK (P2)
.D (1'b0),
.SI (P1),
.SE (P3),
.Q (P1_INT_NET));
 
LATNQ_X1M_A9TH P1_lockup (
 .GN (P2),
.D (P1_INT_NET),
.Q (P5));

#########################


Now FILE1 is very big file having lots of pins like this
Need to match the pattern SI_TESTONLY with other same kind of patterns pins CE0_SE_INPUT_TESTONLY and CE0_TCLK_TESTONLY

and insert the code from the second file into the First File with the replacement
P1 : SI_* Pin
P2 :CE0_TCLK* Pin
P3: CE0_SE_INPUT* Pin
P5: SO_TESTONLY_R_00 Pin

OUTPUT FILE
Smilie
Code:
 
########################
 
input SI_TESTONLY_R_00;
input CE0_SE_INPUT_TESTONLY;
input CE0_TCLK_TESTONLY;
input SI_JTGCLOCKDR_JTAG_R_00;
input CE0_TCLK_JTGCLOCKDR_JTAG;
input CE0_SE_INPUT_JTGCLOCKDR_JTAG;
output SO_TESTONLY_R_00;
output SO_JTGCLOCKDR_JTAG_R_00;
 
SDFFQ_X1M_A9TH SI_TESTONLY_R_00_sdflop (
.CK (CE0_TCLK_TESTONLY)
.D (1'b0),
.SI (SI_TESTONLY_R_00),
.SE (CE0_SE_INPUT_TESTONLY),
.Q (SI_TESTONLY_R_00_INT_NET));
 
LATNQ_X1M_A9TH P1_lockup (
 .GN (CE0_TCLK_TESTONLY),
.D (SI_TESTONLY_R_00_INT_NET),
.Q (SO_TESTONLY_R_00));


SDFFQ_X1M_A9TH SI_JTGCLOCKDR_JTAG_R_00_sdflop (
.CK (CE0_TCLK_JTGCLOCKDR_JTAG)
.D (1'b0),
.SI (SI_JTGCLOCKDR_JTAG_R_00),
.SE (CE0_SE_INPUT_JTGCLOCKDR_JTAG),
.Q (SI_JTGCLOCKDR_JTAG_R_00_INT_NET));
 
LATNQ_X1M_A9TH P1_lockup (
 .GN (CE0_TCLK_JTGCLOCKDR_JTAG),
.D (SI_JTGCLOCKDR_JTAG_R_00_INT_NET),
.Q (SO_JTGCLOCKDR_JTAG_R_00));

I tried to used the array variables but could not build the relevant script on this issue

Please help me out on this

Thanks

Jaita

---------- Post updated at 10:26 AM ---------- Previous update was at 03:22 AM ----------

Anyone Can please help me out in this particular issue

Thanks
Jaita
# 2  
Old 03-11-2011
What have you tried so far (show the code please), where are you stuck, how does your output not match the expected output, ...
We're not here to do your work for you.
# 3  
Old 03-11-2011
Network AWK SCRIPT PROBLEM

I tried the below Flow

I did some vi editing work to create the File as shown below

Code:
 
FILE1 
###########################
 
input SI_TESTONLY_R_00;
input CE0_SE_INPUT_TESTONLY;
input CE0_TCLK_TESTONLY;
output SO_TESTONLY_R_00;

input SI_JTGCLOCKDR_JTAG_R_00;
input CE0_TCLK_JTGCLOCKDR_JTAG;
input CE0_SE_INPUT_JTGCLOCKDR_JTAG;
output SO_JTGCLOCKDR_JTAG_R_00;

but these pins are in different order

Appended the FIle like this

Code:
 
cat FILE2 >> FILE1

Code:
 
awk '{a[FNR]=$2 } END { gsub(P1,a[0]), gsub(P2,a[1], gsub(P3,a[2]) ,gsub(P5,a[3}1' FILE1

Code:
 
cat FILE2 >> FILE1

Code:
 
awk '{a[FNR]=$2 } END { gsub(P1,a[0]), gsub(P2,a[1], gsub(P3,a[2]) ,gsub(P5,a[3}1' FILE1


In this way I am trying to get the output

But it is very messy

Can you help me to make this code more versatile

Issues

a)Sorting of the Pins according to the Pattern match

b) Looping the stuff to insert the Code like the Output File

I did the Initial work before writing the mail and thats why I asked for help , If you think you can help me out I am indebted to you

Thanks
Jaita
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX shell script for matrix insertion into a file

I have a script which is extracting data from a database in an excel file in below given format, date_time calling_app1 count of requests date calling_app x 34 date calling_app y 1034 I want to write a script which will write data into a file like this ... (3 Replies)
Discussion started by: TNT47
3 Replies

2. Shell Programming and Scripting

Awk/sed problem to write Db insertion statement

Hi There, I am trying to load data from a csv file into a DB during our DB migration phase. I am successfully able export all data into a .csv file but those have to rewritten in terms insert statement which will allow for further population of same data in different DB My exiting csv record... (6 Replies)
Discussion started by: bhaskar_m
6 Replies

3. Shell Programming and Scripting

Need help in using sed/awk for line insertion in xml

Hello, I have two text files (txt1 and txt2). txt1 contains many lines with a single number in each line. txt2 (xml format) contains information about the numbers given in txt1. I need to insert one line in txt2 within the scope of each number taken from txt1. Sample problem: txt1: 12 23... (1 Reply)
Discussion started by: shekhar2010us
1 Replies

4. Shell Programming and Scripting

awk script problem

Hi I am having a big file where the interested section is shown below I need to write one awk script to search for the _N thing and delete it till the blank space means _N1 or _N4 everything needs to be deleted Removing the links like _N402 and like that ... (5 Replies)
Discussion started by: jaita
5 Replies

5. Shell Programming and Scripting

awk script problem

Hi, How to check status of the files in the awk script i am having two awk script in one bash script.Like -BELOW is the exact structure of the script script name: new.sh { awk -v v1=`.....` { if (){ exit -1; } } } }'$file name1 { awk -v v2=`.....` { if (){ ... (5 Replies)
Discussion started by: Ganesh Khandare
5 Replies

6. Shell Programming and Scripting

zip code filter problem using AWK need help

Hello all; I have a large file (csv file) with addresses. I am trying to filter out specific entries based on zip code from a particular column of data. However my awk statement can not account for zipcode that begins with a certain pattern. It finds the pattern anywhere within the zipcode. ... (3 Replies)
Discussion started by: nelsonsierra
3 Replies

7. Shell Programming and Scripting

insertion of text from sed script

Hi , This is my first thread ; facing some issues withmy sed script I need to insert the code from my log file which is between two keywords. content is like this ........ log ############################ log1 log2 231 "Ban" "tom" and the line one of the cross line friend... (2 Replies)
Discussion started by: shalini_008
2 Replies

8. Shell Programming and Scripting

Problem with a AWK Script

Hi I am having some contents in my file like this file1 ########################## pin (PIN1) { direction : input ; capacitance : 121 ; max_transition : 231 ; } pin (PIN2) { direction : input ; capacitance : 124 ; max_transition : 421 ;... (8 Replies)
Discussion started by: kshitij
8 Replies

9. Shell Programming and Scripting

Problem with awk script

Hi Can anyone help me in this Problem File1 ######################### HOLI 123 AND ONE TWO THREE AMITABH SAMSUNG POLI AND TWO SENSE CRYING WING PPIN TBFLAG I B AND OROLE TB_HOT=" DCT" TB_CAT=" CAT" TC_NOT=" AND" +PIN TB=" HOT" TB_GATE=" KOT" TB_LATE=" MAT" TC=LOT MAT DAT SAT... (5 Replies)
Discussion started by: kshitij
5 Replies

10. AIX

problem with Unicode characters insertion

hi, I have a problem with unicode chars ( chinese, japanese etc ) insertion using sqlplus prompt. When i wrote a proc program for it i am able to create records. But when i fore the same query on sql prompt it stores reverse ????? ..some junk. widechar columns are mapped with NVARCHAR datatype.... (0 Replies)
Discussion started by: suman_jakkula
0 Replies
Login or Register to Ask a Question