Hi
I have the file called "file.txt" which contains the following output
$cat file.txt
sandy
<version>1</version>
karen
<version>2</version>
Rob
<version>3</version>
peter
<version>4</version>
i want to write a command which will add the value 1 to the digits and show the output like this.
sandy
<version>2</version>
karen
<version>3</version>
Rob
<version>4</version>
peter
<version>5</version>
I have tried using some commands but it seems it is not working or i think i am wrong somewhere .
$ cat file.txt | grep "<version>" | sort -r | uniq | while read line
do
n=`echo $line | cut -f2 -d"<" |cut -f2 -d">"`
nn=`expr $n + 1`
newb="<version>$nn</version>"
sed 's;'${line}';'${newb}';g' file.txt >> file1.txt
mv -f file1.txt file.txt
done
Please help me resolving this problem.
Regards
Siddharth