![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pattern matching in Duplicated file and print once | Danish Shakil | Shell Programming and Scripting | 1 | 08-01-2008 04:55 AM |
| Pattern Matching and lines after that | kaushys | Shell Programming and Scripting | 4 | 06-23-2008 12:27 PM |
| pattern matching over more lines | trek | Shell Programming and Scripting | 3 | 04-22-2008 07:37 AM |
| Reading lines in a file matching a pattern | torenji | Shell Programming and Scripting | 4 | 10-25-2007 05:15 AM |
| pattern matching and print with sed | nymus7 | Shell Programming and Scripting | 2 | 04-14-2005 10:36 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Print block of lines matching a pattern
Hi
,I am using the script to search "MYPATTERN" in MYFILE and print that block of lines containing the pattern starting with HEADER upto FOOTER. But my problem is that at some occurrence my footer is different e.g. ";". How to modify the script so that MYPATTERN between HEADER and different footers can be printed and that too without loosing the sequence. gawk -v search='MYPATTERN' ' /HEADER/,/FOOTER/ { block = (block ? block ORS : "") $0; } /FOOTER/ { if (block ~ search) print block; block = ""; } ' <MYFILE> Also, in this script what to modify if I want to print all thing except MYPATTERN blocks. Please help me in solving this problem. Thnx in advance. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|