title: Linux command to insert multiple lines into xml file
body: <p>Linux command to insert multiple lines into xml file before match/pattern.  Tried with the following command : </p>
  
  <pre><code>#finding pattern:
  toOccurance=`grep -n "\&lt;copy file=\"${appletResource}\/images\/CCMsplash.gif\" toFile=\"${appletbuild}\/splash.gif\" \/&gt;" abc.xml | awk -F: '{print $1}'`
  
  toOccurance=$(($toOccurance -1 ))
  
  sed -i "$toOccurance /a \&lt;copy todir=\"${controlbuild\}\" flatten=\"true\"&gt;\n
                  \&lt;fileset dir=\"${appletResource}\"&gt;\n
                          \&lt;include name=\"crop.properties\"\/&gt;\n
                          \&lt;include name=\"vvm.xml\"\/&gt;\n
                          \&lt;exclude name=\"images\/\*splash.gif\"\/&gt; 
                  &lt;\/fileset&gt;
          &lt;\/copy&gt;" abc.xml
  </code></pre>
  
  <p>No error is shown but the command doesn't work. Any pointers on how to fix it ?</p>