title: Shell command to update pom file from a variable
body: <p>Previously I used below command to take the version in pom.xml and increment it from one. Before increment snapshot version is, <code>0.0.1</code></p>
  
  <pre><code>#!/bin/bash
  
  version=$(grep -ri "&lt;version&gt;" pom.xml |head -n 1 | sed -e 's/^[ \t]* 
  &lt;version&gt;\([^&lt;]*\)&lt;.*$/\1/' | sed 's/[-SNAPSHOT]//g')
  var1=$(echo $version | cut -c1)
  var2=$(echo $version | cut -c2)
  var3=$(echo $version | cut -c3)
  var4=$(echo $version | cut -c4)
  var5=$(echo $version | cut -c5)
  var5=$((var5+1))
  incrementVer=$var1$var2$var3$var4$var5
  echo $incrementVer
  </code></pre>
  
  <p>output <code>is 0.0.2</code></p>
  
  <p>But I want to push this output into pom file and update as, <code>&lt;version&gt;0.0.2&lt;/version&gt;</code></p>
  
  <p>Can I use sed command to update pom file?</p>
  
  <p>My pom file looks like this,</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
  http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.mss.inven&lt;/groupId&gt;
  &lt;artifactId&gt;INVEN&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  </code></pre>