Modifying a row record in an XML file with a shell script
As before, suppose the following XML file:
Web.xml has the following contents:
<param-name>cookieName</param-name>
<param-value>sessionName</param-value>
Requirements: Now you need to replace the value of cookiename with a shell script,
Use the shell to implement the following methods:
Shell Script section:
Declare-i Dline
Getline ()
{
Grep-n "CookieName" ${domain_home}/portal/root/web-inf/web.xml | head-1 | Cut-d ":"-f 1;
}
Getlinenum ()
{
awk "Begin{a= ' getline"; b= "1"; c= (a+b);p rint C} ";
}
Dline= ' Getlinenum ';
echo "line is ${dline}";
Sed-i "${dline},${dline}s/.*/\<param-value\> replacement value \<\/param-value\>/g" Path/web.xml
Description: The difference between this and the previous replacement attribute file is that it is positioned exactly to the line and then replaces the line code.
This XML and properties are the only things that need to be replaced by default.