简体   繁体   English

如何使用Shell脚本从xml删除标签

[英]how to remove tags from xml using shell script

I am using a clean script to clear components from autodeploy in weblogic.This script remove all war files and restarts the weblogic domain {this script just do rm -rf * autodeploy and then restart domain using other script start and stop weblogic scripts}.This script works well, But sometimes,i got problems removing deployments.It removes all components from autodeploy folder but still config.xml have "app-tag" for all components.I dont know why this is happening .but then i have to remove these app-tag from config.xml manually. 我正在使用干净的脚本从weblogic中的自动部署中清除组件。此脚本删除了所有war文件并重新启动了weblogic域(此脚本只执行rm -rf * autodeploy,然后使用其他脚本启动和停止weblogic脚本重新启动域)。脚本运行良好,但是有时我在删除部署时遇到问题。它从autodeploy文件夹中删除了所有组件,但config.xml仍然为所有组件提供了“ app-tag”。我不知道为什么会这样。但是随后我必须删除这些组件手动从config.xml获取app-tag。 This clean script gets in loop saying "componets getting removed"".then i have to do manual work of removing app-tags from config.xml To avoid this manual work : I need your help here,Is there possible way that using SHELL Script we can remove these tags from xml ?? I would like to call this script from within my clean script. Please guide me . 这个干净的脚本进入循环,说“被删除的组件”。然后,我必须完成从config.xml中删除应用程序标签的手动工作,以避免这种手动工作:在这里我需要您的帮助,有没有可能使用SHELL Script的方法?我们可以从xml中删除这些标签??我想从我的干净脚本中调用此脚本,请指导我。

PS : Can't post my clean script right now,But will do if needed later.Altough its just a small script which uses rm-rf and start,stop scripts PS:现在无法发布我的干净脚本,但是以后需要时可以。它只是一个使用rm-rf和start,stop脚本的小脚本

If it's just removing the <app-tag> .. </app-tag> block, you can use sed: 如果只是删除<app-tag> .. </app-tag>块,则可以使用sed:

cp -vi config.xml config.xml-ori
cat config.xml-ori | sed -e '/<app-tag>/, /<\/app-tag>/ d ' > config.xml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM