Unix/Linux Go Back    


UNIX for Beginners Questions & Answers If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Search a string inside a pattern matched block of a file

UNIX for Beginners Questions & Answers


Tags
awk, solved

Reply    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 04-24-2017
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 20 July 2017, 4:54 AM EDT
Location: Aachen, Germany
Posts: 11,050
Thanks: 284
Thanked 3,405 Times in 3,135 Posts
Try

Code:
awk '/START/ {getline BL} /START/,/END/ {if (/string/) print BL, $0}' file

Sponsored Links
    #9  
Old Unix and Linux 04-24-2017
Baishali Baishali is offline
Registered User
 
Join Date: Apr 2017
Last Activity: 24 April 2017, 9:00 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by RudiC View Post
Try

Code:
awk '/START/ {getline BL} /START/,/END/ {if (/string/) print BL, $0}' file

Thank you..I tried it and it works as expected!
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search for Pattern as output between the matched String rahul2662 Shell Programming and Scripting 6 02-27-2016 11:01 AM
How to use sed to search a particular pattern in a file backward after a pattern is matched.? saurabh kumar Shell Programming and Scripting 9 07-20-2013 04:00 PM
Search for a pattern in a String file and count the occurance of each pattern swayam123 Shell Programming and Scripting 4 11-06-2012 02:27 AM
Search and Parse string from inside a File SSims UNIX for Dummies Questions & Answers 2 11-08-2007 02:50 PM
How to search a pattern inside a zipped file ie (.gz file) with out unzipping it senraj01 Shell Programming and Scripting 2 04-26-2006 04:32 AM



All times are GMT -4. The time now is 02:46 PM.