Created
November 1, 2017 13:39
-
-
Save tanepiper/e15bf17e45c82af38c6ef6afcbbaa618 to your computer and use it in GitHub Desktop.
Given a version returned of 1.2.3-beta.0 from the package I only want the "1.2.3" part
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Given a version returned of 1.2.3-beta.0 from the package I only want the "1.2.3" part | |
| grep -m1 version package.json | awk -F: '{ print $2 }' | sed 's/[^0-9.].*//g' | |
| # Running the above command I get an empty output. But if I manually run the result: | |
| echo "1.2.3-beta.0", | sed 's/[^0-9.].*//g' | |
| # I get 1.2.3 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution found:
grep -m1 version package.json | sed -E 's/.*"(([0-9]+\.?)+).*/\1/'