I am trying to get a substring from a line in a file using a shell script. The sticky part is the line in the file is delimited by double quotes. I'm trying to get the string that represents a version number that is between the second set of double quotes.
This is the line in my file:
"parentDirectory/childLibrary": "2.4.177"
I'm trying to extract 2.4.177
and store it in a variable so I can use it later on in my shell script.
Here is my shell script so far:
currentVersion=$(grep '\"parentDirectory/childLibrary\": \"' somefile.txt)
this gets the line that has the version number in it that I want to work with, but I can't figure out how to get what is between the 3rd and 4th double quotes in the string. I can't just say take x
amount of characters starting at position y
because I don't know how long the substring will be. The closest thing I've found is the answer here but I can't figure out how to use this to set a variable equal to the substring I want it to. Any help would be much appreciated. As always, a working answer that is explained clearly will be upvoted and marked as selected answer. Thanks in advance.