Issue with awk script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issue with awk script
# 1  
Old 05-27-2009
Java Issue with awk script

Hi ,

I am using the below awk script

awk '{if($0 ~ /B1/) {set=1; next }; if( $0 ~ /END/) {set = 0}; if (set ) { print }}' CODE | awk '/A \(P1\)/{f=1}f && /}/{print; system("cat $1");f=0;next}1' A.lib > newfile

I need to insert code from CODE file into A.lib file

A.lib file content is

A (P1) {

timing : 10;
cap : 2;
slew : 3;
}
C (P2)

time : 10;
cap : 2;
slew : 3;

}

D (P3)

time : 11;
cap : 4;
slew : 6;
}

A (P1) {

time : 16;
cap : 4;
slew : 7;
}

I could able to enter the code from CODE file while searching the patterns A (P1) but it is not inserting the code for another Block

A (P1) {

time : 16;
cap : 4;
slew : 7;
}

My issue is with Global Replacement with this script whereever it can find A (P1) it should insert the code from CODE file .

I tried to use the g operator but it is not working


Please advice in regards with the same

Thanks
Shalini
# 2  
Old 05-27-2009
This is your 3th thread regarding the same question, the 1st thread with the username kshitij.
Please don't double post questions, read the rules.

Continue on one of these threads:

https://www.unix.com/shell-programmin...t-problem.html

https://www.unix.com/shell-programmin...quirement.html

Thread closed!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue with awk script parsing log file

Hello All, I am trying to parse a log file and i got this code from one of the good forum colleagues, However i realised later there is a problem with this awk script, being naive to awk world wanted to see if you guys can help me out. AWK script: awk '$1 ~ "^WRITER_" {p=1;next}... (18 Replies)
Discussion started by: Ariean
18 Replies

2. Shell Programming and Scripting

awk Script Output in Outlook Formatting Issue

When i execute the below shell script with 2 different Input files, for one of the data files (datafile1) my email message body in the outlook messes up and every thing comes up in one line. May i please know what i am doing wrong here or how to fix this? The only difference in data files is one is... (1 Reply)
Discussion started by: Ariean
1 Replies

3. UNIX for Dummies Questions & Answers

awk script performance issue

Hello All, I have the below excerpt of code in my shell script and it taking long time to complete, though it prints the output quickly. Is there a way to make it come out once it finds the first instance as the file size of 4.7 GB it could be going through all lines of the data file to find for... (3 Replies)
Discussion started by: Ariean
3 Replies

4. Shell Programming and Scripting

awk issue expanding variables in ksh script

Hi Guys, I have an issue with awk and variables. I have trawled the internet and forums but can't seem to get the exactt syntax I need. I have tried using awk -v and all sorts of variations but I have hit a brick wall. I have spent a full day on this and am just going round in circles. ... (3 Replies)
Discussion started by: gazza-o
3 Replies

5. Shell Programming and Scripting

Awk script problem - Variables Causing Issue

can someone please explain to me what i'm doing wrong with this code: WELT=$(awk '(($1 ~ "^${caag}$") || ($2 ~ "^${caag}$"))' /tmp/Compare.TEXT) when run from the command line, it works. but it seems to be having a problem doing the comparison when variables are involved. i tested from... (1 Reply)
Discussion started by: SkySmart
1 Replies

6. Shell Programming and Scripting

Issue with basic Awk script

Here's a basic awk program I am trying to run. It shows no error but shows no result either too. If someone can look up and tell me what's wrong I will be obliged. Thanks. :) Code Snippet. #!/bin/bash awk '{ for (i = 1 ; i <= 3 ; i++) for ( j = 1 ; j <= 3 ; j++ ) { ... (2 Replies)
Discussion started by: mr.amitkc
2 Replies

7. Shell Programming and Scripting

AWK Variable assignment issue Ksh script

Hi There, I am writing a ksh script which assigns variable values from file "A" and passes that variables to file "B". While passing the parameters an additional "$" sign is being assigned to awk -v option. Could any one help me with this please. #!/bin/ksh head -1... (3 Replies)
Discussion started by: Jeevanm
3 Replies

8. Shell Programming and Scripting

Awk script searching patterns issue

Hi I am having a file like this FILE1 ##################### C16ROTINV_ REFCLK_RXL RXBCLK32_R REFCLK_TXL CLK8_TXLIN RXBCLK32_R DCLK_TXLIN CLK32D_TXL RXACLK32_R ##################### (3 Replies)
Discussion started by: jaita
3 Replies

9. Shell Programming and Scripting

AWK script issue for the part regular expression

Hi I am having a file as shown below FILE 1 TXDD00, TXDD01, TXDD02, TXDD03, TXDD04, TXDD05, TXDD06, TXDD07, TXDD08, TXDD09, TXDD10, TXDD11, TXDD12, TXDD13, TXDD14, TXDD15, TXDD16, TXDD17, TXDD18, TXDD19, TXDDCLK, TXDJTAGAMPL0, TXDJTAGAMPL1,... (3 Replies)
Discussion started by: jaita
3 Replies

10. Shell Programming and Scripting

Performance issue with awk script.

Hi, The below awk script is taking about 1 hour to fetch just 11 records(columns). There are about 48000 records. The script file name is take_first_uniq.sh #!/bin/ksh if then while read line do first=`echo $line | awk -F"|" '{print $1$2$3}'` while read line2 do... (4 Replies)
Discussion started by: RRVARMA
4 Replies
Login or Register to Ask a Question