![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Extract a string from a file | kaustubh137 | Shell Programming and Scripting | 20 | 05-24-2008 01:52 AM |
| search file, change existing value based on input (awk help) | nortonloaf | Shell Programming and Scripting | 3 | 12-06-2006 01:35 AM |
| Shell script to return all the ID's from file based on the distribution ID search | kumbhatalok | UNIX for Dummies Questions & Answers | 1 | 10-06-2006 12:53 PM |
| appending string to text file based on search string | malaymaru | Shell Programming and Scripting | 1 | 06-09-2006 08:53 AM |
| How to update the contents in a file conditionally? | rajus19 | Shell Programming and Scripting | 5 | 10-14-2005 03:20 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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> |
| Bookmarks |
| Tags |
| unresolved, unresolved for months, unresolved for weeks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|