Sponsored Content
Full Discussion: Parse string
Top Forums Shell Programming and Scripting Parse string Post 302350964 by Scrutinizer on Sunday 6th of September 2009 03:48:21 PM
Old 09-06-2009
Oops misread you requirements...
I guess you would need two statements
Code:
j=${i/.com}
dom=${j//.}

or
Code:
dom=$(echo $i|sed -e's/\.com//;s/\.//g')

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

parse a string variable

Hello all, need a little help. I have an input variable such as ARGV which equals something like /use/home/name/script/test.dat I need to be able to get just the "test.dat" (i.e. the file name) at the end of the directory and the directory can be anything and any length. To put it another... (3 Replies)
Discussion started by: methos
3 Replies

2. Shell Programming and Scripting

String parse question

I have a string of data that looks like this: private.enterprises.954.1.1.1.1.1.2618 \(OctetString\): U private.enterprises.954.1.1.1.1.2.2618 \(OctetString\): 2618 I am trying to parse the string to only return the values after the ":". Ex from above "U" and "2618". Any suggestions? (5 Replies)
Discussion started by: mnreferee
5 Replies

3. Shell Programming and Scripting

how to parse this string

I want to get filenames from the following input. How can I parse this in bash. input data ------------------------------------------------------------------- path=/aaa/bbb/filename1;/aaa/filename2;/aaa/bbb/ccc/ddd/filename3 -------------------------------------------------------------------... (13 Replies)
Discussion started by: hcliff
13 Replies

4. Shell Programming and Scripting

Parse String Using Sed

Hi, I am wondering if there's a simpler way to extract the second occurrence of a word enclosed in that matches my search criteria. Sample Input is as follows: Error installing feature - com.er.nms.cif.ist.NoMatchingUpgra Error installing feature -... (4 Replies)
Discussion started by: racbern
4 Replies

5. UNIX for Dummies Questions & Answers

parse string with awk

Hi Guys, I spend half a day getting this to work with no luck, perhaps you guys can help.. I have a string from a file looking like this: module::name=test::type=generic_data::exec=snmpget.......::desc=A Little Test::interval=300 what I would like to split it, so I get a value for each... (3 Replies)
Discussion started by: hyber
3 Replies

6. Shell Programming and Scripting

How to parse a string into variables

I'm working in korn shell and have a variable which contains a string like: aa_yyyymmdd_bbb_ccc_ddd.abc. I want to treat the _ and . as delimiters and parse the string so I end up with 6 values in variables that I can manipulate. My original plan was to use var1=`echo $sting1 | cut -c1-c2` but... (9 Replies)
Discussion started by: aquimby
9 Replies

7. Shell Programming and Scripting

Search string and parse

Input file 0792 to 2450 iadmssql7: Copy: CNJ R1: Replication volumes: Replication set: RSet 1 Replication size: 200.00GB SAN Info: 200.00GB DGC VRAID CX4-960 LUN 17 (17) RPA Port WWN Ctrl ... (0 Replies)
Discussion started by: greycells
0 Replies

8. Shell Programming and Scripting

Parse a string as a command

I've a problem parsing a string as a command: Consider script stefano.sh as following: #!/usr/bin/sh txtshell="./parser.sh /ews/MyEventHandler/data/handler/StopAndMail.php eventid=StopAndMail.MVIN.6300 lot_number=1122FXB facility=EWSF3 'mailto=prova.prova@nohost.com, prova.test@nohost.com'... (2 Replies)
Discussion started by: buonstefano
2 Replies

9. Shell Programming and Scripting

parse a mixed alphanumeric string from within a string

Hi, I would like to be able to parse out a substring matching a basic pattern, which is a character followed by 3 or 4 digits (for example S1234 out of a larger string). The main string would just be a filename, like Thisis__the FileName_S1234_ToParse.txt. The filename isn't fixed, but the... (2 Replies)
Discussion started by: keaneMB
2 Replies

10. Programming

Perl parse string

Hi Perl Guys I have another perl question I have the following code that i have written Getopt::Long::config(qw( permute bundling )); my $OPT = {}; GetOptions($OPT, qw( ver=s help|h )) or die "options parsing failed"; This will allow the user to do something like... (4 Replies)
Discussion started by: ab52
4 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 02:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy