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

时间:2021-10-09 00:25:51

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. 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 .

我正在使用一个干净的脚本来清除weblogic中autodeploy的组件。这个脚本删除所有war文件并重新启动weblogic域{此脚本只需执行rm -rf * autodeploy然后使用其他脚本启动和停止weblogic脚本重新启动域}。脚本运行良好,但有时,我有问题删除部署。它从autodeploy文件夹中删除所有组件,但仍然config.xml具有所有组件的“app-tag”。我不知道为什么会发生这种情况。但是我必须删除这些来自config.xml的app-tag手动。这个干净的脚本循环说“组件被删除”“。然后我必须手动工作从config.xml中删除app-tags要避免这种手动工作:我需要你的帮助,有没有办法使用SHELL Script我们可以从xml中删除这些标签吗?我想从我的干净脚本中调用这个脚本。请指导我。

P.S : 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

P.S:现在不能发布我的干净脚本了,但是如果需要的话可以稍后发布。虽然它只是一个使用rm-rf并启动的小脚本,但是停止脚本

1 个解决方案

#1


0  

If it's just removing the <app-tag> .. </app-tag> block, you can use sed:

如果只是删除 .. 块,则可以使用sed:

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

#1


0  

If it's just removing the <app-tag> .. </app-tag> block, you can use sed:

如果只是删除 .. 块,则可以使用sed:

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