bash script to edit xml file

前端 未结 4 1974
再見小時候
再見小時候 2021-02-06 00:53

I want to edit the config file of a program that is an XML:


   
       ...
       

        
4条回答
  •  攒了一身酷
    2021-02-06 01:19

    Using xmlstarlet:

    xmlstarlet val -e file.xml
    xmlstarlet ed -u "//settings/setting/@name" -v 'local directory2' file.xml
    xmlstarlet ed -u "//settings[1]/setting/@name" -v 'local directory2' file.xml
    
    # edit file inplace
    xmlstarlet ed -L -u "//settings/setting/@name" -v 'local directory2' file.xml  
    

提交回复
热议问题