Sponsored Content
Top Forums Shell Programming and Scripting Grepping a word from a .xml file dynamically Post 302794893 by hanson44 on Wednesday 17th of April 2013 02:20:33 AM
Old 04-17-2013
I think this is what you need:
Code:
$ cat file.xml
 <Head="Test"  Id="3" >
            <Title="mode" >

Code:
$ cat temp.sh
Head=`grep Head file.xml | sed 's/.*Head="\([^"]*\)".*/Head=\1'/`
Title=`grep Title file.xml | sed 's/.*Title="\([^"]*\)".*/Title=\1'/`
echo $Head
echo $Title

Code:
$ ./temp.sh
Head=Test
Title=mode

-------------------------

Another way to get rid of the "" characters, using your existing code, would be to add to the end of your pipeline:
Code:
tr -d '"'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

BASH: Grepping/sedding/etc out part of a file... (from one word to 'blank' line)

I have a file that lists data about a system. It has a part that can look like: the errors I'm looking for with other errors: Alerts Password Incorrect Login Error Another Error Another Error 2 Other Info or, just the errors I need to parse for: Alerts Password Incorrect ... (9 Replies)
Discussion started by: elinenbe
9 Replies

2. Shell Programming and Scripting

search a word in a xml file and print the out put

hi , i m having a html file and this file looks like this <ssl> <name>PIA</name> <enabled>true</enabled> <listen-port>39370</listen-port> </ssl> <log> <name>PIA</name> </log> <execute-queue> <name>weblogic.kernel.Default</name> ... (7 Replies)
Discussion started by: becksram123
7 Replies

3. Shell Programming and Scripting

Search for word in a xml file and replace it with something else

Hello Unix Users, I am very new to Unix so I am not sure how do I do the following. I need a script such that when I type the following in the command prompt > . scriptName.sh wordToBeReplaced DirectoryLocation will find the word someword located in a somefile.xml in DirectoryLocation... (8 Replies)
Discussion started by: 5211171
8 Replies

4. Shell Programming and Scripting

Grepping word based on white space.....

Hi, I am having a text file with following contents: word word I want to grep the first line i.e. word that is being preceded with three space characters. So i tried sed -n '/ {3}/p' filename grep " {3}" filename But is not returning any result. If i don't use {}, then it... (5 Replies)
Discussion started by: sarbjit
5 Replies

5. Shell Programming and Scripting

word counts for a single line xml file

I have any XML ouput file(file name TABLE.xml), where the data is loaded in A SINGLE LINE, I need help in writting a ksh shell script which gives me the word counts of word <TABLE-ROW> This is my input file. <?xml version="1.0" encoding="UTF-8"?><!--Generated by Ascential Software... (4 Replies)
Discussion started by: pred55
4 Replies

6. Shell Programming and Scripting

Grepping more than one word

Dear Experts, Need your help. Typically we use "grep" to search and display a pattern in a txt file. However, here what we want is, we want to grep a line which contains 4 words any where in a line. For example. File has 10,000,000 lines in it out of which there is a particular line which... (1 Reply)
Discussion started by: anushree.a
1 Replies

7. Shell Programming and Scripting

How to find a word and move it a specific location in xml file using perl?

Hi friends, I have one XML file having below structure :- INput XML file :- <?xml version="1.0" encoding="UTF-8"?> <START> <A=value1> <attr name1="a1"> </A> <B=value2> <attr name2="b1"> <attr name3="c1"> </B> </START> output xml file should be === (3 Replies)
Discussion started by: harpal singh
3 Replies

8. Shell Programming and Scripting

Grepping a word from a .xml file

Hi I have a xml file vi lpower.xml <head = power_health> Now, I need to grep "power_health" alone from that file using shell.. Please help (3 Replies)
Discussion started by: Priya Amaresh
3 Replies

9. Shell Programming and Scripting

Replacing a particular word with another word in all the xml's under a particular directory with sed

Hi Folks, Could you please advise what will be the SED command to replace a word in all xml's under a particular directory for example let say I rite now at the following below location $ cd /ter/rap/config now under config directory there will be lots of xml file , now my objective is to... (1 Reply)
Discussion started by: punpun66
1 Replies

10. UNIX for Beginners Questions & Answers

Grepping multiple XML tag results from XML file.

I want to write a one line script that outputs the result of multiple xml tags from a XML file. For example I have a XML file which has below XML tags in the file: <EMAIL>***</EMAIL> <CUSTOMER_ID>****</CUSTOMER_ID> <BRANDID>***</BRANDID> Now I want to grep the values of all these specified... (1 Reply)
Discussion started by: shubh752
1 Replies
__gnu_pbds::detail::pat_trie_base::_Node___gnu_pbds::detail::pat_trie_base::_Node_iter<rNode, Leaf,cHead, Inode, _CIterator, Iterator, _Alloc >(3)

NAME
__gnu_pbds::detail::pat_trie_base::_Node_iter< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc > - SYNOPSIS
Inherits __gnu_pbds::detail::pat_trie_base::_Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >. Public Types typedef _Alloc::template rebind< metadata_type > __rebind_m" typedef __rebind_m::other __rebind_ma typedef value_type const_reference typedef trivial_iterator_difference_type difference_type" typedef trivial_iterator_tag iterator_category typedef __rebind_ma::const_reference metadata_const_reference" typedef Node::metadata_type metadata_type typedef value_type reference typedef base_type::size_type size_type typedef Iterator value_type Public Member Functions _Node_iter (node_pointer p_nd=0, a_const_pointer p_traits=0) _Node_iter get_child (size_type i) const metadata_const_reference get_metadata () const size_type num_children () const bool operator!= (const _Node_citer &other) const reference operator* () const bool operator== (const _Node_citer &other) const std::pair< a_const_iterator, a_const_iterator > valid_prefix () const " Public Attributes node_pointer m_p_nd a_const_pointer m_p_traits Protected Types typedef _Alloc::template rebind< Inode > __rebind_in" typedef _Alloc::template rebind< Leaf > __rebind_l" typedef Node::a_const_iterator a_const_iterator typedef __rebind_in::other::const_pointer inode_const_pointer" typedef __rebind_l::other::const_pointer leaf_const_pointer" typedef __rebind_l::other::pointer leaf_pointer Detailed Description template<typename Node, typename Leaf, typename Head, typename Inode, typename _CIterator, typename Iterator, typename _Alloc>class __gnu_pbds::detail::pat_trie_base::_Node_iter< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc > Node iterator. Definition at line 943 of file pat_trie_base.hpp. Member Typedef Documentation template<typename Node , typename Leaf , typename Head , typename Inode , typename _CIterator , typename Iterator , typename _Alloc > typedef _Alloc::template rebind<metadata_type> __gnu_pbds::detail::pat_trie_base::_Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::__rebind_m [inherited] Const metadata reference type. Definition at line 869 of file pat_trie_base.hpp. template<typename Node , typename Leaf , typename Head , typename Inode , typename _CIterator , typename Iterator , typename _Alloc > typedef Node::metadata_type __gnu_pbds::detail::pat_trie_base::_Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::metadata_type [inherited] Metadata type. Definition at line 866 of file pat_trie_base.hpp. Member Function Documentation template<typename Node , typename Leaf , typename Head , typename Inode , typename _CIterator , typename Iterator , typename _Alloc > _Node_iter __gnu_pbds::detail::pat_trie_base::_Node_iter< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::get_child (size_typei) const [inline] Returns a node __iterator to the corresponding node's i-th child. Definition at line 976 of file pat_trie_base.hpp. References std::advance(), and std::begin(). template<typename Node , typename Leaf , typename Head , typename Inode , typename _CIterator , typename Iterator , typename _Alloc > metadata_const_reference __gnu_pbds::detail::pat_trie_base::_Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::get_metadata () const [inline], [inherited] Metadata access. Definition at line 894 of file pat_trie_base.hpp. template<typename Node , typename Leaf , typename Head , typename Inode , typename _CIterator , typename Iterator , typename _Alloc > size_type __gnu_pbds::detail::pat_trie_base::_Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::num_children () const [inline], [inherited] Returns the number of children in the corresponding node. Definition at line 899 of file pat_trie_base.hpp. References std::distance(). Referenced by __gnu_pbds::detail::pat_trie_base::_Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::operator*(), and __gnu_pbds::detail::pat_trie_base::_Node_iter< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::operator*(). template<typename Node , typename Leaf , typename Head , typename Inode , typename _CIterator , typename Iterator , typename _Alloc > bool __gnu_pbds::detail::pat_trie_base::_Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::operator!= (const _Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc > &other) const [inline], [inherited] Compares content (negatively) to a different iterator object. Definition at line 927 of file pat_trie_base.hpp. template<typename Node , typename Leaf , typename Head , typename Inode , typename _CIterator , typename Iterator , typename _Alloc > reference __gnu_pbds::detail::pat_trie_base::_Node_iter< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::operator* () const [inline] Access; returns the iterator* associated with the current leaf. Definition at line 968 of file pat_trie_base.hpp. References __gnu_pbds::detail::pat_trie_base::_Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::num_children(). template<typename Node , typename Leaf , typename Head , typename Inode , typename _CIterator , typename Iterator , typename _Alloc > bool __gnu_pbds::detail::pat_trie_base::_Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::operator== (const _Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc > &other) const [inline], [inherited] Compares content to a different iterator object. Definition at line 922 of file pat_trie_base.hpp. template<typename Node , typename Leaf , typename Head , typename Inode , typename _CIterator , typename Iterator , typename _Alloc > std::pair<a_const_iterator, a_const_iterator> __gnu_pbds::detail::pat_trie_base::_Node_citer< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >::valid_prefix () const [inline], [inherited] Subtree valid prefix. Definition at line 880 of file pat_trie_base.hpp. References std::make_pair(). Author Generated automatically by Doxygen for libstdc++ from the source code. libstdc++ __gnu_pbds::detail::pat_trie_base::_Node_iter< Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc >(3)
All times are GMT -4. The time now is 05:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy