I have a text file with contents:(version.txt)
#Project Name: XYZ
#Module Name: ABC
#
#
currentVersion=9.2.04
Now I have a shell script as shown below which replaces last line of version.txt to currentVersion=9.2.05
script:
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
but instead it gives o/p like this:
currentVersion=05
currentVersion=05
currentVersion=05
currentVersion=05
currentVersion=05
currentVersion=05
currentVersion=05
Can you please tell me what is wrong in this script?
Thanks in advance