I want to be able to retrieve a version number (n.n.n) from a file (yaml) that follows a string.
sdk: ">=0.2.4 <3.1.1"
version: ^2.3.1
sdk: flutter
version: 1.0.0+1
sed -n '/version:/p sample.yaml
which returns the line for the string provided "version:", I then piped this into another command grep to pattern match the line for the version number:
sed -n '/version:/p sample.yaml | grep -oP '(\[0-9\]+).(\[0-9\]+).(\[0-9\]+)'
I would like to see if there is a more efficient way to do this, and if string = 'sdk' from the example the returned value returns both when I would like to return a single value.
I would like to return a single value- which value and based on what criteria?