sed exceptions / if else condition on deleting word on xml

后端 未结 2 1716
梦毁少年i
梦毁少年i 2020-12-21 16:38

I am currently using a sed script:

cd (root folder) first

find . -name pom.xml | xargs sed -i \"//,/\'<\\/dependencies>\'/s         


        
2条回答
  •  没有蜡笔的小新
    2020-12-21 17:30

    By using XSLT technologies:

    STYLESHEET:

    $ more pomConvertor.xslt 
    
    
    
        
        
    
        
        
            
                
            
        
    
    
        
            
        
    
    
    

    INPUT:

    $ more pom.xml 
    
     
        com.techstack.scheduler
        scheduler-service
        0.0.9-SNAPSHOT
     
    
        scheduler-webapp
        war
        Scheduler Service Web Application
        http://maven.apache.org
    
    
        
            com.infor.techstack.scheduler
            scheduler-service-core
            0.0.9-SNAPSHOT
        
    
        
            org.slf4j
            slf4j-api
            1.7.12-SNAPSHOT
            provided
        
        
            com.security.authentication
            oauth10a-client
            0.0.26-SNAPSHOT
            compile
            
                
                    xerces
                    xerces
                
            
            
    
    
    

    OUTPUT:

    $ xsltproc pomConvertor.xslt pom.xml                                                                                             
    
    
      
        com.techstack.scheduler
        scheduler-service
        0.0.9-SNAPSHOT
      
      scheduler-webapp
      war
      Scheduler Service Web Application
      http://maven.apache.org
      
        
          com.infor.techstack.scheduler
          scheduler-service-core
          0.0.9-SNAPSHOT
        
        
          org.slf4j
          slf4j-api
          1.7.12
          provided
        
        
          com.security.authentication
          oauth10a-client
          0.0.26
          compile
          
            
              xerces
              xerces
            
          
        
      
    
    

提交回复
热议问题