Bash shell script: Str(007) to int(7),increment it(8) & convert back t
Hi, I have the following requirement. There will be following text/line in a file (eg: search-build.txt) PRODUCT_VERSION="V:01.002.007.Build1234" I need to update the incremental build number (eg here 007) every time I give a build through script. I am able to search the string and get the item. Quote: rexpression_sed='PRODUCT_VERSION=\"V:\([0-9]*\).\([0-9]*\).\([0-9]*\).Build\([0-9]*\)\"' var2=`grep -sn $rexpression_sed search-build.txt | sed -e 's/'$rexpression_sed'/\1\t\2\t\3\t\4/g'| cut -f 3` echo $var2 007 How to convert this to integer (7), add 1 to it (8) and again get back in the same form (008) in the easiest way? I will be using sed -i on the file, with this new string that can be used with RE for replacing that part! Or Is there any better method than above. Thanks for any help. |
No comments:
Post a Comment