Advanced AWK Regexp substring to int & Replace

Hi!

I have a difficult problem, to step up a unknown version number in a text file, and save the file. It would be great to run script.sh and the version gets increased.
Example the content of the textfile.txt
hello
version = x
bye

This include three steps

  1. First find the char after "version =" e.g 5
  2. Convert? the 5 to a integer and increase the value with 1, in this case result is 6
  3. Replace the 5 with a 6
  4. save the file

I understand this is a VERY difficult problem, if you can in any way it would be great, i tried with SED earlyer, but got stuck.

Thanks in advance
Beachboy72

VERSION=`cat textfile.txt | grep version | awk '{print $3}'`
VERSION=`expr $VERSION + 1`

Actually, it is a very trivial problem. Here is one way of doing it.

#!/bin/bash

while read a b c
do
   [[ "$a $b" == "version =" ]] && (( c++ ))
   echo "$a $b $c"
done < infile