Sponsored Content
Top Forums Shell Programming and Scripting Print lines between two strings multiple occurencies (with sed, awk, or grep) Post 302595343 by ahamed101 on Thursday 2nd of February 2012 10:01:46 PM
Old 02-02-2012
Code:
sed -n '/debut_sect/,/fin_sect/{s/fin_sect/--END OF BLOCK--/;/debut_sect/d;p}' infile

--ahamed
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print only lines in between two strings using awk

Hi, I want to print only lines in between two strings and not the strings using awk. Eg: OUTPUT top 2 bottom 1 left 0 right 0 page 66 END I want to print into a new file only top 2 bottom 1 left 0... (4 Replies)
Discussion started by: jisha
4 Replies

2. UNIX for Dummies Questions & Answers

print multiple lines with awk

Hi everyone! I'm not new to Unix, but I've never used awk before. I tried to look up this information on several sites and forums, I also looked in the documentation but I haven't found a solution yet. I would like to print the previous 3 lines before and the following 4 lines after the... (6 Replies)
Discussion started by: djcsabus
6 Replies

3. Shell Programming and Scripting

How to get lines started with matched strings using sed or grep for loop?

I have a huge file and want to separate it into several subsets. The file looks like: C1 C2 C3 C4 ... (variable names) 1 .... 2 .... 3 .... : 22 .... 23 .... I want to separate the huge file using the column 1, which has numbers from 1 to 23 (but there are different amount of... (8 Replies)
Discussion started by: AMBER
8 Replies

4. Shell Programming and Scripting

print multiple lines using the grep command.

Hi All, Please find my piece of code below. I am trying to grep the word SUCCESS from $LOGFILE and storing in the grepvar variable. And i am placing that variable in a file. Now if i open the file, i can see the four lines but not in seperate four line s but in a paragraph. If am mailing that log... (8 Replies)
Discussion started by: intiraju
8 Replies

5. UNIX for Dummies Questions & Answers

best method of replacing multiple strings in multiple files - sed or awk? most simple preferred :)

Hi guys, say I have a few files in a directory (58 text files or somthing) each one contains mulitple strings that I wish to replace with other strings so in these 58 files I'm looking for say the following strings: JAM (replace with BUTTER) BREAD (replace with CRACKER) SCOOP (replace... (19 Replies)
Discussion started by: rich@ardz
19 Replies

6. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

7. Shell Programming and Scripting

Sed or Awk for lines between two strings multiple times and keep the last one

Hi, I am trying to get lines between the last occurrences of two patterns. I have files that have several occurrences of “Standard” and “Visual”. I will like to get the lines between “Standard” and “Visual” but I only want to retain only the last one e.g. Standard Some words Some words Some... (4 Replies)
Discussion started by: damanidada
4 Replies

8. Shell Programming and Scripting

How to print the lines between the pattern using awk/grep/sed?

Hi, I need a help to search a pattern and print the multiple lines between them. Input file: Tue May 29 12:30:33 EDT 2012:threadWebContainer : 357:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request: ... (4 Replies)
Discussion started by: aroragaurav.84
4 Replies

9. UNIX for Beginners Questions & Answers

How to find=grep or maybe sed/awk for multiple lines of text?

Hi, I am running the following: PASS="username/password" sqlplus -s << EOF | grep -v "^$" $PASS set feedback off set heading off set termout off select name from v\$database ; exit EOF Which gives ERROR: ORA-28002: the password will expire within 5 days PSMP1 (1 Reply)
Discussion started by: newbie_01
1 Replies

10. Shell Programming and Scripting

awk or sed or grep filter a line and/or between strings

Hi, I have multiple files on a directory with the following content: blahblah blahblah hostname server1 blahblah blahblah ---BEGIN--- aaa bbb ccc ddd ---END--- blahblah blahblah blahblah I would like to filter all the files with awk or sed or something else so I can get below... (6 Replies)
Discussion started by: bayupw
6 Replies
Template::Plugin::XML::DOM(3pm) 			User Contributed Perl Documentation			   Template::Plugin::XML::DOM(3pm)

NAME
Template::Plugin::XML::DOM - Plugin interface to XML::DOM SYNOPSIS
# load plugin [% USE dom = XML.DOM %] # also provide XML::Parser options [% USE dom = XML.DOM(ProtocolEncoding = 'ISO-8859-1') %] # parse an XML file [% doc = dom.parse(filename) %] [% doc = dom.parse(file = filename) %] # parse XML text [% doc = dom.parse(xmltext) %] [% doc = dom.parse(text = xmltext) %] # call any XML::DOM methods on document/element nodes [% FOREACH node = doc.getElementsByTagName('report') %] * [% node.getAttribute('title') %] # or [% node.title %] [% END %] # define VIEW to present node(s) [% VIEW report notfound='xmlstring' %] # handler block for a <report>...</report> element [% BLOCK report %] [% item.content(view) %] [% END %] # handler block for a <section title="...">...</section> element [% BLOCK section %] <h1>[% item.title %]</h1> [% item.content(view) %] [% END %] # default template block converts item to string [% BLOCK xmlstring; item.toString; END %] # block to generate simple text [% BLOCK text; item; END %] [% END %] # now present node (and children) via view [% report.print(node) %] # or print node content via view [% node.content(report) %] # following methods are soon to be deprecated in favour of views [% node.toTemplate %] [% node.childrenToTemplate %] [% node.allChildrenToTemplate %] DESCRIPTION
This is a Template Toolkit plugin interfacing to the XML::DOM module. The plugin loads the XML::DOM module and creates an XML::DOM::Parser object which is stored internally. The parse() method can then be called on the plugin to parse an XML stream into a DOM document. [% USE dom = XML.DOM %] [% doc = dom.parse('/tmp/myxmlfile') %] The XML::DOM plugin object (i.e. 'dom' in these examples) acts as a sentinel for the documents it creates ('doc' and any others). When the plugin object goes out of scope at the end of the current template, it will automatically call dispose() on any documents that it has cre- ated. Note that if you dispose of the the plugin object before the end of the block (i.e. by assigning a new value to the 'dom' variable) then the documents will also be disposed at that point and should not be used thereafter. [% USE dom = XML.DOM %] [% doc = dom.parse('/tmp/myfile') %] [% dom = 'new value' %] # releases XML.DOM plugin and calls # dispose() on 'doc', so don't use it! The plugin constructor will also accept configuration options destined for the XML::Parser object: [% USE dom = XML.DOM(ProtocolEncoding = 'ISO-8859-1') %] METHODS
parse() The parse() method accepts a positional parameter which contains a filename or XML string. It is assumed to be a filename unless it con- tains a < character. [% xmlfile = '/tmp/foo.xml' %] [% doc = dom.parse(xmlfile) %] [% xmltext = BLOCK %] <xml> <blah><etc/></blah> ... </xml> [% END %] [% doc = dom.parse(xmltext) %] The named parameters 'file' (or 'filename') and 'text' (or 'xml') can also be used: [% doc = dom.parse(file = xmlfile) %] [% doc = dom.parse(text = xmltext) %] The parse() method returns an instance of the XML::DOM::Document object representing the parsed document in DOM form. You can then call any XML::DOM methods on the document node and other nodes that its methods may return. See XML::DOM for full details. [% FOREACH node = doc.getElementsByTagName('CODEBASE') %] * [% node.getAttribute('href') %] [% END %] This plugin also provides an AUTOLOAD method for XML::DOM::Node which calls getAttribute() for any undefined methods. Thus, you can use the short form of [% node.attrib %] in place of [% node.getAttribute('attrib') %] PRESENTING DOM NODES USING VIEWS
You can define a VIEW to present all or part of a DOM tree by automatically mapping elements onto templates. Consider a source document like the following: <report> <section title="Introduction"> <p> Blah blah. <ul> <li>Item 1</li> <li>item 2</li> </ul> </p> </section> <section title="The Gory Details"> ... </section> </report> We can load it up via the XML::DOM plugin and fetch the node for the <report> element. [% USE dom = XML.DOM; doc = dom.parse(file = filename); report = doc.getElementsByTagName('report') %] We can then define a VIEW as follows to present this document fragment in a particular way. The Template::Manual::Views documentation con- tains further details on the VIEW directive and various configuration options it supports. [% VIEW report_view notfound='xmlstring' %] # handler block for a <report>...</report> element [% BLOCK report %] [% item.content(view) %] [% END %] # handler block for a <section title="...">...</section> element [% BLOCK section %] <h1>[% item.title %]</h1> [% item.content(view) %] [% END %] # default template block converts item to string representation [% BLOCK xmlstring; item.toString; END %] # block to generate simple text [% BLOCK text; item; END %] [% END %] Each BLOCK defined within the VIEW represents a presentation style for a particular element or elements. The current node is available via the 'item' variable. Elements that contain other content can generate it according to the current view by calling [% item.content(view) %]. Elements that don't have a specific template defined are mapped to the 'xmlstring' template via the 'notfound' parameter specified in the VIEW header. This replicates the node as an XML string, effectively allowing general XML/XHTML markup to be passed through unmodified. To present the report node via the view, we simply call: [% report_view.print(report) %] The output from the above example would look something like this: <h1>Introduction</h1> <p> Blah blah. <ul> <li>Item 1</li> <li>item 2</li> </ul> </p> <h1>The Gory Details</h1> ... To print just the content of the report node (i.e. don't process the 'report' template for the report node), you can call: [% report.content(report_view) %] AUTHORS
This plugin module was written by Andy Wardley and Simon Matthews. The XML::DOM module is by Enno Derksen and Clark Cooper. It extends the the XML::Parser module, also by Clark Cooper which itself is built on James Clark's expat library. COPYRIGHT
Copyright (C) 2000-2006 Andy Wardley, Simon Matthews. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Plugin, XML::DOM, XML::Parser perl v5.8.8 2008-03-01 Template::Plugin::XML::DOM(3pm)
All times are GMT -4. The time now is 09:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy