![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep and delete lines except the lines with strings | vj8436 | Shell Programming and Scripting | 14 | 04-17-2009 11:25 AM |
| retrieve lines that match a pattern | fadista | UNIX for Dummies Questions & Answers | 2 | 12-10-2008 04:40 AM |
| retrieve lines from file which fall under the given date range | Sharmila_P | Shell Programming and Scripting | 5 | 07-31-2008 08:30 AM |
| grep and fetching lines after grep | arghya_owen | Shell Programming and Scripting | 2 | 07-16-2008 07:25 AM |
| retrieve text after grep | frustrated1 | UNIX for Dummies Questions & Answers | 2 | 12-16-2006 11:42 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
retrieve lines using sed, grep or awk
Hi,
I'm looking for a command to retrieve a block of lines using sed or grep, probably awk if that can do the job. In below example, By searching for words "Third line2" i'm expecting to retrieve the full block starting with 'BEGIN' and ending with 'END' of the search. Example: BEGIN Second line Third line1 Fourth line END BEGIN Second line Third line2 Fourth line END BEGIN Second line Third line3 Fourth line END Output Expecting: BEGIN Second line Third line2 Fourth line END Note: Block line size can vary & each block can have different line sizes from one other. Thank you Last edited by learning_linux; 03-31-2009 at 12:45 AM.. |