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

前端 未结 3 521
滥情空心
滥情空心 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:40

    This might work for you (GNU sed & Bash):

    CONTENT='    \
        NewName\
        NewID\
    '
    
    sed '/<\/Students>/i\'"$CONTENT" file
    

    Alternatively, put the new students in a file and:

    sed '/<\/Students>/e cat new_student_file' file
    

提交回复
热议问题