Sponsored Content
Top Forums Shell Programming and Scripting Reporting lines above a particular pattern Post 302661265 by dll_fpga on Monday 25th of June 2012 06:08:10 AM
Old 06-25-2012
Please tell me how its working...
also will this work if there are multiple reports in a file say
Code:
Startpoint: ff1
               (rising edge-triggered flip-flop clocked by CLK3)
 Endpoint: ff4
               (rising clock gating-check end-point clocked by CLK4)
  Path Group: good
  Path Type: min
  Point                                                                                                                  
  ----------------------------------
  clock CLK1 (rise edge)                                                                                       
  clock network delay (propagated)      
VIOL   =  10              



Startpoint: ff5
               (rising edge-triggered flip-flop clocked by CLK6)
 Endpoint: ff7
               (rising clock gating-check end-point clocked by CLK40)
  Path Group: bad
  Path Type: min
  Point                                                                                                                  
  ----------------------------------
  clock CLK1 (rise edge)                                                                                       
  clock network delay (propagated)      
test
VIOL   =  15              




Startpoint: ff90
               (rising edge-triggered flip-flop clocked by CLK3f
 Endpoint: ff46
               (rising clock gating-check end-point clocked by CLK4f)
  Path Group: good
  Path Type: min
  Point                                                                                                                  
  ----------------------------------
  clock CLK1 (rise edge)                                                                                       
  clock network delay (propagated)      
VIOL   =  105





output should be
Code:
Startpoint: ff1
                (rising edge-triggered flip-flop clocked by CLK3)
  Endpoint: ff4
                (rising clock gating-check end-point clocked by CLK4)
VIOL   =  10              
Startpoint: ff90
                (rising edge-triggered flip-flop clocked by CLK3f
  Endpoint: ff46
                (rising clock gating-check end-point clocked by CLK4f)
VIOL   =  105


Quote:
Originally Posted by itkamaraj
Code:
 
$ awk '/Path.*good/{a=1}!a{line=line"\n"$0}/VIOL/{if(a){print line"\n"$0}}' input.txt
Startpoint: ff1
(rising edge-triggered flip-flop clocked by CLK3)
Endpoint: ff4
(rising clock gating-check end-point clocked by CLK4)
VIOL = 10 

          



also please tell me how this is working
thanks

---------- Post updated at 03:16 PM ---------- Previous update was at 03:13 PM ----------

which parameter should i modify if i need some more lines before the "path group" filed...
Quote:
Originally Posted by itkamaraj
Code:
 
$ awk '/Path.*good/{a=1}!a{line=line"\n"$0}/VIOL/{if(a){print line"\n"$0}}' input.txt
Startpoint: ff1
(rising edge-triggered flip-flop clocked by CLK3)
Endpoint: ff4
(rising clock gating-check end-point clocked by CLK4)
VIOL = 10

Moderator's Comments:
Mod Comment Please use code tags, thanks!


---------- Post updated at 03:38 PM ---------- Previous update was at 03:16 PM ----------

Please give any alternate command to do the same
.......
or pls tell me which parameter should i modify to get more than 2 lines preceding the pattern..lets say 5 lines

Quote:
Originally Posted by itkamaraj
Code:
 
$ awk '/Path.*good/{a=1}!a{line=line"\n"$0}/VIOL/{if(a){print line"\n"$0}}' input.txt
Startpoint: ff1
(rising edge-triggered flip-flop clocked by CLK3)
Endpoint: ff4
(rising clock gating-check end-point clocked by CLK4)
VIOL = 10


Last edited by zaxxon; 06-25-2012 at 06:51 AM.. Reason: code tags, see PM
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

counting the lines matching a pattern, in between two pattern, and generate a tab

Hi all, I'm looking for some help. I have a file (very long) that is organized like below: >Cluster 0 0 283nt, >01_FRYJ6ZM12HMXZS... at +/99% 1 279nt, >01_FRYJ6ZM12HN12A... at +/99% 2 281nt, >01_FRYJ6ZM12HM4TS... at +/99% 3 283nt, >01_FRYJ6ZM12HM946... at +/99% 4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies

2. Shell Programming and Scripting

sed pattern to delete lines containing a pattern, except the first occurance

Hello sed gurus. I am using ksh on Sun and have a file created by concatenating several other files. All files contain header rows. I just need to keep the first occurrence and remove all other header rows. header for file 1111 2222 3333 header for file 1111 2222 3333 header for file... (8 Replies)
Discussion started by: gary_w
8 Replies

3. UNIX for Dummies Questions & Answers

Matching and reporting near-similar lines in a file

Hi, I have a file with the lines as below: C_10_A05_T7 C_10_A06_SP6 C_10_B05_SP6 C_10_B05_T7 C_10_B01_SP6 C_10_B01_T7 C_12_G07_SP6 C_12_G11_SP6 C_12_G11_T7 C_2_H18_T7 C_2_I02_SP6 C_2_I02_T7 C_2_I13_SP6 C_2_I17_SP6 The four segments of each line are connected by '_' symbols. I... (7 Replies)
Discussion started by: Fahmida
7 Replies

4. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

5. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

6. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies

7. UNIX for Dummies Questions & Answers

Grep -v lines starting with pattern 1 and not matching pattern 2

Hi all! Thanks for taking the time to view this! I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern. Example: Drink a soda Eat a banana Eat multiple bananas Drink an apple juice Eat an apple Eat multiple apples I... (8 Replies)
Discussion started by: demmel
8 Replies

8. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

9. Shell Programming and Scripting

How to delete all lines before a particular pattern when the pattern is defined in a variable?

I have a file Line 1 a Line 22 Line 33 Line 1 b Line 22 Line 1 c Line 4 Line 5 I want to delete all lines before last occurrence of a line which contains something which is defined in a variable. Say a variable var contains 'Line 1', then I need the following in the output. ... (21 Replies)
Discussion started by: Soham
21 Replies

10. Shell Programming and Scripting

[sed] Finding and sticking the pattern to the beginning of successive lines up to the next pattern

I have a file like below. 2018.07.01, Sunday 09:27 some text 123456789 0 21 0.06 0.07 0.00 2018.07.02, Monday 09:31 some text 123456789 1 41 0.26 0.32 0.00 09:39 some text 456789012 1 0.07 0.09 0.09 09:45 some text 932469494 1 55 0.29 0.36 0.00 16:49 some text 123456789 0 48 0.12 0.15 0.00... (9 Replies)
Discussion started by: father_7
9 Replies
All times are GMT -4. The time now is 01:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy