It is currently Mon, 27 Jun 2022 12:44:00 GMT

Author Message
 Extract specific text from file using sed

I have an XML file and I want to do the following on the lines 3 - 60
(inclusive). They all have the same format:

<resourceProperties xmi:id="J2EEResourceProperty_1125491012986"
name="access" type="java.lang.String" value="all"
description="description is here."/>

I want to be able to extract the segment - name="access"
type="java.lang.String" value="all" .

So in effect I want to delete two sections on each of the lines between
3 and 60. The part of the line up to "name" and the part which starts
with "description".

Anyone help?



 Wed, 03 Dec 2008 17:20:30 GMT   
 Extract specific text from file using sed

If only the lines 3 to 60 are to be modified and printed...

   sed -n "3,60s/.*\(name=.*\) description=.*/\1/p"

If lines 3 to 60 are to be modified and all other lines printed unmodified...

   sed    "3,60s/.*\(name=.*\) description=.*/\1/"


- Show quoted text -

 Wed, 03 Dec 2008 18:24:22 GMT   
 Extract specific text from file using sed
Perfect Janis, thank you!

 Thu, 04 Dec 2008 18:36:24 GMT   
   [ 3 post ] 

Similar Threads

1. Sed: Replace text in one file with SPECIFIC text from another

2. Find First Match Using SED and Then Extract Text from Line

3. Extracting lines from inside a text file (question for sed expert)

4. help with sed extracting email address from text file

5. Extracting lines from a text file that match a certain criteria to another text file

6. extracting fields by keyword from large text file, using bash

7. Script to extract portions of text from a text file

8. Need some advice on checking/editing text files using sed

9. Extract string from this text (sed)

10. extracting a specific file from an RPM package

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software