Find the answer to your Linux question:
Results 1 to 2 of 2
I have a group of xml files and I need to insert 3 parameters just after this line in each file: ---------------Pattern to be searched for------------------------- <!--The following configuration is ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2005
    Posts
    3

    Sed command


    I have a group of xml files and I need to insert 3 parameters just after this line in each file:
    ---------------Pattern to be searched for-------------------------
    <!--The following configuration is a test configuration-->

    ---------------Parameters to be added---------------------------
    <Parameter>
    <Name>NamedThreadsEnableLocking</Name>
    <Value>true</Value>
    </Parameter>

    <Parameter>
    <Name>Test1</Name>
    <Value>true</Value>
    </Parameter>

    <Parameter>
    <Name>Test2</Name>
    <Value>true</Value>
    </Parameter>

    Can anyone help me implement this with the sed command? Thanks in advance.

  2. #2
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    Put this in a file:
    Code:
    /target/a\
    Insertion
    Where target is what you're inserting after, and Insertion is what you're inserting. To run, use this:
    Code:
    sed -f file changeMe
    Where file has your sed commands in it, and changeMe is the file to change.
    Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    Registered Linux User #408794

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •