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

awk, solved

Thread Tools Search this Thread Display Modes
Old Unix and Linux 04-24-2017
RudiC RudiC is offline Forum Staff  
Join Date: Jul 2012
Last Activity: 21 October 2017, 1:23 PM EDT
Location: Aachen, Germany
Posts: 11,480
Thanks: 310
Thanked 3,561 Times in 3,276 Posts

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

Sponsored Links
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
Originally Posted by RudiC View Post

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

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

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 08:48 PM.