I have a file with lines:
[tree]:1,"asdf"
[box]:2,"yuio"
[bee]:10,"rtyu"
[cup]:15,"bnmv"
[tree]:13,"asdf"
and I want the output to be
[tree]:2,"asdf"
[box]:2,"yuio"
[bee]:10,"rtyu"
[cup]:15,"bnmv"
[tree]:14,"asdf"
So I need to increment the [tree] value by 1. I need some way to search each line for [tree], copy the number next to it which may be more than 2 digits, and then increment this number. I have done this in Matlab but it is painfully slow, and involves rewriting the entire file. I'm looking for a faster alternative, like a bash script or maybe something in python.