Sponsored Content
Top Forums Shell Programming and Scripting Read content between xml tags with awk, grep, awk or what ever... Post 302402767 by alister on Wednesday 10th of March 2010 03:07:50 PM
Old 03-10-2010
Sebi0815:

The following is about as smart as your original solution; it will not work correctly if this tag can be embedded within itself, nor if there are multiple instances of it on a single line. If you require more intelligence, perhaps it is time to step up to a tool that understands xml.

Code:
$ cat data
<tag2>Hello
Linux-
User</tag2>

<tag3>DO NOT PRINT
DO NOT PRINT
DO NOT PRINT</tag3>
<tag2>Good Bye</tag2>

$ sed -n '/<tag2>/,/<\/tag2>/H; /<tag2>/h; /\/tag2/{x;s/<tag2>\(.*[^\n]\)\n*<\/tag2>/\1/p;}' data
Hello
Linux-
User
Good Bye

Cheers,
Alister
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help with awk - how to read a content of a file from every file from file list

Hi Experts. I need to list the file and the filename comes from the file ListOfFile.txt. Basicly I have a filename "ListOfFile.txt" and it contain Example of ListOfFile.txt /home/Dave/Program/Tran1.P /home/Dave/Program/Tran2.P /home/Dave/Program/Tran3.P /home/Dave/Program/Tran4.P... (7 Replies)
Discussion started by: tanit
7 Replies

2. UNIX for Dummies Questions & Answers

Using Awk within awk to read all files in directory

I am wondering if anyone has any idea how to use an awk within awk to read files and find a match which adds to count. Say I am searching how many times the word crap appears in each files within a directory. How would i do that from the command prompt ... thanks (6 Replies)
Discussion started by: flevongo
6 Replies

3. Shell Programming and Scripting

Read a file content with awk and sed

Hello , I have huge file with below content. I need to read the numeric values with in the paranthesis after = sign. Please help me with awk and sed script for it. 11.10.2009 04:02:47 Customer login not found: identifier=(0748502889) prefix=(TEL) serviceCode=(). 11.10.2009 04:03:12... (13 Replies)
Discussion started by: rmv
13 Replies

4. Shell Programming and Scripting

Help on awk to read xml file

Hello, I have a xml file as shown below. I want to parse the file and store data in variables. xml file looks like: <TEST NAME="DataBaseurl">jdbc:oracle:thin:@localhost:1521:ora10</TEST> <TEST NAME="Databaseuser">Pradeep</TEST> ...... and many other such lines i want to read this file and... (2 Replies)
Discussion started by: pradeepmacha
2 Replies

5. Shell Programming and Scripting

how to get tags content by grep

1) Is it possible to get tags content by grep -E ? For example title. Source text "<title>My page<title>"; to print "My page". 2) which bash utility to use when I want to use regex in this format? (?<=title>).*(?=</title) (11 Replies)
Discussion started by: visitor123
11 Replies

6. Shell Programming and Scripting

awk to retrieve the particular value from a same list of xml tags

Hi All, I have the following code in one of my xml file: <com:parameter> <com:name>secretKey</com:name> <com:value>31XA874821172E89B00B1C</com:value> </com:parameter> <com:parameter> <com:name>tryDisinfect</com:name> <com:value>false</com:value> </com:parameter> <com:parameter>... (4 Replies)
Discussion started by: mjavalkar
4 Replies

7. Shell Programming and Scripting

awk and or sed command to sum the value in repeating tags in a XML

I have a XML in which <Amt Ccy="EUR">3.1</Amt> tag repeats. This is under another tag <Main>. I need to sum all the values of <Amt Ccy=""> (Ccy may vary) coming under <Main> using awk and or sed command. can some help? Sample looks like below <root> <Main> ... (6 Replies)
Discussion started by: bk_12345
6 Replies

8. Shell Programming and Scripting

How to add Xml tags to an existing xml using shell or awk?

Hi , I have a below xml: <ns:Body> <ns:result> <Date Month="June" Day="Monday:/> </ns:result> </ns:Body> i have a lookup abc.txtt text file with below details Month June July August Day Monday Tuesday Wednesday I need a output xml with below tags <ns:Body> <ns:result>... (2 Replies)
Discussion started by: Nevergivup
2 Replies

9. UNIX for Dummies Questions & Answers

Grep content in xml file

I have an xml file with header as below. <Provider xmlns="http://www.xyzx.gov/xyz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xyzx.gov/xyz xyz.xsd" SCHEMA_VERSION="2.5" PROVIDER="5"> I want to get the schema version here that is 2.5 and put in a... (7 Replies)
Discussion started by: Ariean
7 Replies

10. UNIX for Dummies Questions & Answers

Piping grep into awk, read the next line using grep

Hi, I have a number of files containing the information below. """"" Fundallinfo 6.3950 14.9715 14.0482 """"" I would like to grep for Fundallinfo and use it to read the next line? I ideally would like to read the three numbers that follow in the next line and... (2 Replies)
Discussion started by: Paul Moghadam
2 Replies
DateTime::Locale::fil(3)				User Contributed Perl Documentation				  DateTime::Locale::fil(3)

NAME
DateTime::Locale::fil SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'fil' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Filipino. DATA
This locale inherits from the DateTime::Locale::root locale. It contains the following data. Days Wide (format) Lunes Martes Miyerkules Huwebes Biyernes Sabado Linggo Abbreviated (format) Lun Mar Mye Huw Bye Sab Lin Narrow (format) L M M H B S L Wide (stand-alone) Lunes Martes Miyerkules Huwebes Biyernes Sabado Linggo Abbreviated (stand-alone) Lun Mar Mye Huw Bye Sab Lin Narrow (stand-alone) L M M H B S L Months Wide (format) Enero Pebrero Marso Abril Mayo Hunyo Hulyo Agosto Setyembre Oktubre Nobyembre Disyembre Abbreviated (format) Ene Peb Mar Abr May Hun Hul Ago Set Okt Nob Dis Narrow (format) E P M A M H H A S O N D Wide (stand-alone) Enero Pebrero Marso Abril Mayo Hunyo Hulyo Agosto Setyembre Oktubre Nobyembre Disyembre Abbreviated (stand-alone) Ene Peb Mar Abr May Hun Hul Ago Set Okt Nob Dis Narrow (stand-alone) E P M A M H H A S O N D Quarters Wide (format) Q1 Q2 Q3 Q4 Abbreviated (format) Q1 Q2 Q3 Q4 Narrow (format) 1 2 3 4 Wide (stand-alone) Q1 Q2 Q3 Q4 Abbreviated (stand-alone) Q1 Q2 Q3 Q4 Narrow (stand-alone) 1 2 3 4 Eras Wide BCE CE Abbreviated BCE CE Narrow BCE CE Date Formats Full 2008-02-05T18:30:30 = Martes, Pebrero 05 2008 1995-12-22T09:05:02 = Biyernes, Disyembre 22 1995 -0010-09-15T04:44:23 = Sabado, Setyembre 15 -10 Long 2008-02-05T18:30:30 = Pebrero 5, 2008 1995-12-22T09:05:02 = Disyembre 22, 1995 -0010-09-15T04:44:23 = Setyembre 15, -10 Medium 2008-02-05T18:30:30 = Peb 5, 2008 1995-12-22T09:05:02 = Dis 22, 1995 -0010-09-15T04:44:23 = Set 15, -10 Short 2008-02-05T18:30:30 = 2/5/08 1995-12-22T09:05:02 = 12/22/95 -0010-09-15T04:44:23 = 9/15/-10 Default 2008-02-05T18:30:30 = Peb 5, 2008 1995-12-22T09:05:02 = Dis 22, 1995 -0010-09-15T04:44:23 = Set 15, -10 Time Formats Full 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Long 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Medium 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Short 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 Default 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Datetime Formats Full 2008-02-05T18:30:30 = Martes, Pebrero 05 2008 18:30:30 UTC 1995-12-22T09:05:02 = Biyernes, Disyembre 22 1995 09:05:02 UTC -0010-09-15T04:44:23 = Sabado, Setyembre 15 -10 04:44:23 UTC Long 2008-02-05T18:30:30 = Pebrero 5, 2008 18:30:30 UTC 1995-12-22T09:05:02 = Disyembre 22, 1995 09:05:02 UTC -0010-09-15T04:44:23 = Setyembre 15, -10 04:44:23 UTC Medium 2008-02-05T18:30:30 = Peb 5, 2008 18:30:30 1995-12-22T09:05:02 = Dis 22, 1995 09:05:02 -0010-09-15T04:44:23 = Set 15, -10 04:44:23 Short 2008-02-05T18:30:30 = 2/5/08 18:30 1995-12-22T09:05:02 = 12/22/95 09:05 -0010-09-15T04:44:23 = 9/15/-10 04:44 Default 2008-02-05T18:30:30 = Peb 5, 2008 18:30:30 1995-12-22T09:05:02 = Dis 22, 1995 09:05:02 -0010-09-15T04:44:23 = Set 15, -10 04:44:23 Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 Mar 1995-12-22T09:05:02 = 22 Bye -0010-09-15T04:44:23 = 15 Sab Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 PM 1995-12-22T09:05:02 = 9:05 AM -0010-09-15T04:44:23 = 4:44 AM Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 PM 1995-12-22T09:05:02 = 9:05:02 AM -0010-09-15T04:44:23 = 4:44:23 AM M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (M-d) 2008-02-05T18:30:30 = 2-5 1995-12-22T09:05:02 = 12-22 -0010-09-15T04:44:23 = 9-15 MEd (E, M-d) 2008-02-05T18:30:30 = Mar, 2-5 1995-12-22T09:05:02 = Bye, 12-22 -0010-09-15T04:44:23 = Sab, 9-15 MMM (LLL) 2008-02-05T18:30:30 = Peb 1995-12-22T09:05:02 = Dis -0010-09-15T04:44:23 = Set MMMd (MMM d) 2008-02-05T18:30:30 = Peb 5 1995-12-22T09:05:02 = Dis 22 -0010-09-15T04:44:23 = Set 15 MMMEd (E MMM d) 2008-02-05T18:30:30 = Mar Peb 5 1995-12-22T09:05:02 = Bye Dis 22 -0010-09-15T04:44:23 = Sab Set 15 MMMMd (MMMM d) 2008-02-05T18:30:30 = Pebrero 5 1995-12-22T09:05:02 = Disyembre 22 -0010-09-15T04:44:23 = Setyembre 15 MMMMEd (E MMMM d) 2008-02-05T18:30:30 = Mar Pebrero 5 1995-12-22T09:05:02 = Bye Disyembre 22 -0010-09-15T04:44:23 = Sab Setyembre 15 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (yyyy-M) 2008-02-05T18:30:30 = 2008-2 1995-12-22T09:05:02 = 1995-12 -0010-09-15T04:44:23 = -010-9 yMEd (EEE, yyyy-M-d) 2008-02-05T18:30:30 = Mar, 2008-2-5 1995-12-22T09:05:02 = Bye, 1995-12-22 -0010-09-15T04:44:23 = Sab, -010-9-15 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 Peb 1995-12-22T09:05:02 = 1995 Dis -0010-09-15T04:44:23 = -10 Set yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = Mar, 2008 Peb 5 1995-12-22T09:05:02 = Bye, 1995 Dis 22 -0010-09-15T04:44:23 = Sab, -10 Set 15 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 Pebrero 1995-12-22T09:05:02 = 1995 Disyembre -0010-09-15T04:44:23 = -10 Setyembre yQ (y Q) 2008-02-05T18:30:30 = 2008 1 1995-12-22T09:05:02 = 1995 4 -0010-09-15T04:44:23 = -10 3 yQQQ (y QQQ) 2008-02-05T18:30:30 = 2008 Q1 1995-12-22T09:05:02 = 1995 Q4 -0010-09-15T04:44:23 = -10 Q3 yyMM (yy-MM) 2008-02-05T18:30:30 = 08-02 1995-12-22T09:05:02 = 95-12 -0010-09-15T04:44:23 = -10-09 yyMMM (MMM yy) 2008-02-05T18:30:30 = Peb 08 1995-12-22T09:05:02 = Dis 95 -0010-09-15T04:44:23 = Set -10 Miscellaneous Prefers 24 hour time? Yes Local first day of the week Lunes SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.18.2 2017-10-06 DateTime::Locale::fil(3)
All times are GMT -4. The time now is 07:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy