Adding XML element in XML file using sed command in shell script

前端 未结 3 522
滥情空心
滥情空心 2020-12-18 03:51

I am using sed command to insert an xml element into the existing xml file.

I have xml file as


    
        

        
3条回答
  •  青春惊慌失措
    2020-12-18 04:49

    change this:

    CONTENT="
                NewName
                NewID
            "
    

    to this:

    CONTENT="\nNewName\nNewID\n"
    

    and then:

    C=$(echo $CONTENT | sed 's/\//\\\//g')
    sed "/<\/Students>/ s/.*/${C}\n&/" file
    

提交回复
热议问题