Sponsored Content
Top Forums Shell Programming and Scripting using sed to conditionally extract stanzas of a file based on a search string Post 302261839 by aitayemi on Tuesday 25th of November 2008 05:16:08 PM
Old 11-25-2008
using sed to conditionally extract stanzas of a file based on a search string

Dear All,
I have a file with the syntax below (composed of several <log ..... </log> stanzas)
I need to search this file for a number e.g. 2348022225919, and if it is found in a stanza, copy the whole stanza/section (<log .... </log>) to another output file.

The numbers to search for are listed in an input file (easy enough to read that file in one line at a time), but I am having major problems trying to build a conditional instruction using sed to search the file (below) for a particular number and then copy its whole section if a match is found. Thanks.

<log logid="847b00c2190810312356170828/1/1/1">
<category>ProcEngineBL.Normal</category>
<operation>Get</operation>
<target>GsmFlex.Connection</target>
<instance>msisdn=2348022225919</instance>
<user>tester1</user>
<context>sog.Pro/context>
<status>SUCCESSFUL</status>
</log>
<log logid="827b00c43190810312356170828/1/2/1">
<category>ProcEngineBL.Normal</category>
<operation>Set</operation>
<target>GsmFlex.Connection</target>
<instance>msisdn=234802225919</instance>
<user>onwer1</user>
<context>sog.Pro/context>
<status>SUCCESSFUL</status>
</log>
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

appending string to text file based on search string

Hi, I need to append string "Hi" to the beginning of the lines containing some specific string. How can I achieve that? Please help. Malay (1 Reply)
Discussion started by: malaymaru
1 Replies

2. Shell Programming and Scripting

Search for string in a file and extract another string to a variable

Hi, guys. I have one question: I need to search for a string in a file, and then extract another string from the file and assign it to a variable. For example: the contents of the file (group) is below: ... ftp:x:23: mail:x:34 ... testing:x:2001 sales:x:2002 development:x:2003 ...... (6 Replies)
Discussion started by: daikeyang
6 Replies

3. Shell Programming and Scripting

Extracting data between tags based on search string from unix file

Input file is on Linux box and the input file has data in just one line with 1699741696 characters. Sample Input: <xxx><document coll="uspatfull" version="0"><CMSdoc>xxxantivirus</CMSdoc><tag1>1</tag1></document><document coll="uspatfull"... (5 Replies)
Discussion started by: gaya
5 Replies

4. Shell Programming and Scripting

Extract string from multiple file based on line count number

Hi, I search all forum, but I can not find solutions of my problem :( I have multiple files (5000 files), inside there is this data : FILE 1: 1195.921 -898.995 0.750312E-02-0.497526E-02 0.195382E-05 0.609417E-05 -2021.287 1305.479-0.819754E-02 0.107572E-01 0.313018E-05 0.885066E-05 ... (15 Replies)
Discussion started by: guns
15 Replies

5. Shell Programming and Scripting

Use grep sed or awk to extract string from log file and put into CSV

I'd like to copy strings from a log file and put them into a CSV. The strings could be on different line numbers, depending on size of log. Example Log File: File = foo.bat Date = 11/11/11 User = Foo Bar Size = 1024 ... CSV should look like: "foo.bat","11/11/11","Foo Bar","1024" (7 Replies)
Discussion started by: chipperuga
7 Replies

6. Shell Programming and Scripting

bash script to find date based on search string for continuesly updating file

Hi All, I am very new to UNIX and I have tried this for a longtime now and unable to crack it.... There is a file that is continuously updating. I need to search for the string and find the date @ which it updated every day..... eg: String is "work started" The log entry is as below: ... (1 Reply)
Discussion started by: Nithz
1 Replies

7. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

8. Shell Programming and Scripting

Search for string in a file, extract two another strings and concatenate to a variable

I have a file with <suit:run date="Trump Tue 06/19/2012 11:41 AM EDT" machine="garg-ln" build="19921" level="beta" release="6.1.5" os="Linux"> Need to find word "build" then extract build number, which is 19921 also release number, which is 6.1.5 then concatenate them to one variable as... (6 Replies)
Discussion started by: garg
6 Replies

9. UNIX for Dummies Questions & Answers

Obtaining File information based on String Search

Is there a single Command in Unix to get the following Information when searching for files containing one or more strings in a Unix Directory (including sub directories within it) : 1) Complete filename ( path and filename) 2) Owner of the file 3) Size of the file 4) Last Modified date... (3 Replies)
Discussion started by: pchegoor
3 Replies

10. Shell Programming and Scripting

How to search and replace string in column in file with command sed?

how to search and replace string in column in file with command sed or other search "INC0000003.in" and replace column 4 = "W" $ cat file.txt INC0000001.in|20150120|Y|N|N INC0000002.in|20150120|Y|N|N INC0000003.in|20150120|Y|N|N INC0000004.in|20150120|Y|N|Noutput... (4 Replies)
Discussion started by: ppmanja3
4 Replies
DateTime::Locale::ga(3pm)				User Contributed Perl Documentation				 DateTime::Locale::ga(3pm)

NAME
DateTime::Locale::ga - DateTime locale package for "ga" SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'ga' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Irish. DATA
This locale inherits from the DateTime::Locale::root locale. It contains the following data. Days Wide (format) De Luain De Mairt De Ceadaoin Deardaoin De hAoine De Sathairn De Domhnaigh Abbreviated (format) Luan Mairt Cead Dear Aoine Sath Domh Narrow (format) L M C D A S D Wide (stand-alone) De Luain De Mairt De Ceadaoin Deardaoin De hAoine De Sathairn De Domhnaigh Abbreviated (stand-alone) Luan Mairt Cead Dear Aoine Sath Domh Narrow (stand-alone) L M C D A S D Months Wide (format) Eanair Feabhra Marta Aibrean Bealtaine Meitheamh Iuil Lunasa Mean Fomhair Deireadh Fomhair Samhain Nollaig Abbreviated (format) Ean Feabh Marta Aib Beal Meith Iuil Lun MFomh DFomh Samh Noll Narrow (format) E F M A B M I L M D S N Wide (stand-alone) Eanair Feabhra Marta Aibrean Bealtaine Meitheamh Iuil Lunasa Mean Fomhair Deireadh Fomhair Samhain Nollaig Abbreviated (stand-alone) Ean Feabh Marta Aib Beal Meith Iuil Lun MFomh DFomh Samh Noll Narrow (stand-alone) E F M A B M I L M D S N Quarters Wide (format) 1u raithe 2u raithe 3u raithe 4u raithe Abbreviated (format) R1 R2 R3 R4 Narrow (format) 1 2 3 4 Wide (stand-alone) 1u raithe 2u raithe 3u raithe 4u raithe Abbreviated (stand-alone) R1 R2 R3 R4 Narrow (stand-alone) 1 2 3 4 Eras Wide Roimh Chriost Anno Domini Abbreviated RC AD Narrow RC AD Date Formats Full 2008-02-05T18:30:30 = De Mairt 5 Feabhra 2008 1995-12-22T09:05:02 = De hAoine 22 Nollaig 1995 -0010-09-15T04:44:23 = De Sathairn 15 Mean Fomhair -10 Long 2008-02-05T18:30:30 = 5 Feabhra 2008 1995-12-22T09:05:02 = 22 Nollaig 1995 -0010-09-15T04:44:23 = 15 Mean Fomhair -10 Medium 2008-02-05T18:30:30 = 5 Feabh 2008 1995-12-22T09:05:02 = 22 Noll 1995 -0010-09-15T04:44:23 = 15 MFomh -10 Short 2008-02-05T18:30:30 = 05/02/2008 1995-12-22T09:05:02 = 22/12/1995 -0010-09-15T04:44:23 = 15/09/-010 Default 2008-02-05T18:30:30 = 5 Feabh 2008 1995-12-22T09:05:02 = 22 Noll 1995 -0010-09-15T04:44:23 = 15 MFomh -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 = De Mairt 5 Feabhra 2008 18:30:30 UTC 1995-12-22T09:05:02 = De hAoine 22 Nollaig 1995 09:05:02 UTC -0010-09-15T04:44:23 = De Sathairn 15 Mean Fomhair -10 04:44:23 UTC Long 2008-02-05T18:30:30 = 5 Feabhra 2008 18:30:30 UTC 1995-12-22T09:05:02 = 22 Nollaig 1995 09:05:02 UTC -0010-09-15T04:44:23 = 15 Mean Fomhair -10 04:44:23 UTC Medium 2008-02-05T18:30:30 = 5 Feabh 2008 18:30:30 1995-12-22T09:05:02 = 22 Noll 1995 09:05:02 -0010-09-15T04:44:23 = 15 MFomh -10 04:44:23 Short 2008-02-05T18:30:30 = 05/02/2008 18:30 1995-12-22T09:05:02 = 22/12/1995 09:05 -0010-09-15T04:44:23 = 15/09/-010 04:44 Default 2008-02-05T18:30:30 = 5 Feabh 2008 18:30:30 1995-12-22T09:05:02 = 22 Noll 1995 09:05:02 -0010-09-15T04:44:23 = 15 MFomh -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 Mairt 1995-12-22T09:05:02 = 22 Aoine -0010-09-15T04:44:23 = 15 Sath HHmm (HH:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 HHmmss (HH:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 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 p.m. 1995-12-22T09:05:02 = 9:05 a.m. -0010-09-15T04:44:23 = 4:44 a.m. 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 p.m. 1995-12-22T09:05:02 = 9:05:02 a.m. -0010-09-15T04:44:23 = 4:44:23 a.m. M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (d/M) 2008-02-05T18:30:30 = 5/2 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/9 MEd (E, M-d) 2008-02-05T18:30:30 = Mairt, 2-5 1995-12-22T09:05:02 = Aoine, 12-22 -0010-09-15T04:44:23 = Sath, 9-15 MMdd (dd/MM) 2008-02-05T18:30:30 = 05/02 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/09 MMM (LLL) 2008-02-05T18:30:30 = Feabh 1995-12-22T09:05:02 = Noll -0010-09-15T04:44:23 = MFomh MMMd (MMM d) 2008-02-05T18:30:30 = Feabh 5 1995-12-22T09:05:02 = Noll 22 -0010-09-15T04:44:23 = MFomh 15 MMMEd (E MMM d) 2008-02-05T18:30:30 = Mairt Feabh 5 1995-12-22T09:05:02 = Aoine Noll 22 -0010-09-15T04:44:23 = Sath MFomh 15 MMMMd (d MMMM) 2008-02-05T18:30:30 = 5 Feabhra 1995-12-22T09:05:02 = 22 Nollaig -0010-09-15T04:44:23 = 15 Mean Fomhair MMMMEd (E MMMM d) 2008-02-05T18:30:30 = Mairt Feabhra 5 1995-12-22T09:05:02 = Aoine Nollaig 22 -0010-09-15T04:44:23 = Sath Mean Fomhair 15 mmss (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 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 (y-M) 2008-02-05T18:30:30 = 2008-2 1995-12-22T09:05:02 = 1995-12 -0010-09-15T04:44:23 = -10-9 yMEd (EEE, y-M-d) 2008-02-05T18:30:30 = Mairt, 2008-2-5 1995-12-22T09:05:02 = Aoine, 1995-12-22 -0010-09-15T04:44:23 = Sath, -10-9-15 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 Feabh 1995-12-22T09:05:02 = 1995 Noll -0010-09-15T04:44:23 = -10 MFomh yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = Mairt, 2008 Feabh 5 1995-12-22T09:05:02 = Aoine, 1995 Noll 22 -0010-09-15T04:44:23 = Sath, -10 MFomh 15 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 Feabhra 1995-12-22T09:05:02 = 1995 Nollaig -0010-09-15T04:44:23 = -10 Mean Fomhair 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 R1 1995-12-22T09:05:02 = 1995 R4 -0010-09-15T04:44:23 = -10 R3 yyMM (MM/yy) 2008-02-05T18:30:30 = 02/08 1995-12-22T09:05:02 = 12/95 -0010-09-15T04:44:23 = 09/-10 yyMMM (MMM yy) 2008-02-05T18:30:30 = Feabh 08 1995-12-22T09:05:02 = Noll 95 -0010-09-15T04:44:23 = MFomh -10 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 yyyyMM (MM/yyyy) 2008-02-05T18:30:30 = 02/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 09/-010 yyyyMMMM (MMMM y) 2008-02-05T18:30:30 = Feabhra 2008 1995-12-22T09:05:02 = Nollaig 1995 -0010-09-15T04:44:23 = Mean Fomhair -10 Miscellaneous Prefers 24 hour time? Yes Local first day of the week De Luain 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.10.1 2010-03-19 DateTime::Locale::ga(3pm)
All times are GMT -4. The time now is 06:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy