how to edit XML using bash script?

后端 未结 4 1277
终归单人心
终归单人心 2020-11-29 11:29

1
2

Need to change values 1 and 2 from bash

4条回答
  •  盖世英雄少女心
    2020-11-29 12:05

    To change tag's value to 2 and tag1's value to 3, using XMLStarlet:

    xmlstarlet ed \
      -u '/root/tag' -v 2 \
      -u '/root/tag1' -v 3 \
      new.xml
    

    Using your sample input:

    xmlstarlet ed \
      -u '/root/tag' -v 2 \
      -u '/root/tag1' -v 3 \
      <<<'12'
    

    ...emits as output:

    
    
      2
      3
    
    

提交回复
热议问题