title: Need help in sed and awk commands
body: <p>I have a text file with contents:(version.txt)</p>
  
  <pre><code>#Project Name: XYZ
  #Module Name: ABC
  #
  #
  currentVersion=9.2.04
  </code></pre>
  
  <p>Now I have a shell script as shown below which replaces last line of version.txt to <code>currentVersion=9.2.05</code></p>
  
  <p>script:</p>
  
  <pre><code>ls_version=`grep -i currentVersion version.txt | awk '{print $NF}'`
  counter=`echo $ls_version | awk -F . '{print $NF}'`
  fs_version=`echo $ls_version | awk -F"." -v OFS='.' '{$NF=""; print $0}'`
  echo "counter b4 addition: $counter"
  counter=`expr ${counter} + 1`
  version=`echo ${fs_version}$counter`
  echo "ls_version: $ls_version"
  echo "fs_version: $fs_version"
  echo "counter post addition: $counter"
  echo "final version: $version"
  sed -i -e "s/\(currentVersion=\).*/\1$version/" version.txt
  </code></pre>
  
  <p>but instead it gives o/p like this:</p>
  
  <pre><code>currentVersion=05
  currentVersion=05
  currentVersion=05
  currentVersion=05
  currentVersion=05
  currentVersion=05
  currentVersion=05
  </code></pre>
  
  <p>Can you please tell me what is wrong in this script?</p>
  
  <p>Thanks in advance</p>