文件里有一行 public string strVersion = "34"; 用bash shell怎么只取 34 并且 +1 后再保存文件 文件保存后 應(yīng)該是 public string strVersion = "35";
小伙看你根骨奇佳,潛力無限,來學(xué)PHP伐。
Looking at the syntax, it feels like JAVA system
It may be possible to use search and regex.
But I think you can consider writing a class BashHelperConsole. This class refers to the class to which your strVersion belongs, and then Console provides a public method to output strVersion to stdout; your bash can use the java command line to directly call this BashHelperConsole class. , use the return as the variable content, in the form:
strVersion=$( calling_command )
I always do this in my projects, because I output what I want, so it is correct. It just requires the two languages ??to cooperate with each other.
I hope the "one line" you mentioned really looks like that, with nothing more and nothing less.
awk '/public string strVersion = "[0-9]+";/ { d = substr(, 2, length()-3); sub(d, d+1); }; 1'