Last active
January 6, 2024 14:02
-
-
Save bitmvr/9ed42e1cc2aac799b123de9fdc59b016 to your computer and use it in GitHub Desktop.
Parsing SemVer with Bash
This file contains 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
#!/usr/bin/env bash | |
VERSION="$1" | |
VERSION="${VERSION#[vV]}" | |
VERSION_MAJOR="${VERSION%%\.*}" | |
VERSION_MINOR="${VERSION#*.}" | |
VERSION_MINOR="${VERSION_MINOR%.*}" | |
VERSION_PATCH="${VERSION##*.}" | |
echo "Version: ${VERSION}" | |
echo "Version [major]: ${VERSION_MAJOR}" | |
echo "Version [minor]: ${VERSION_MINOR}" | |
echo "Version [patch]: ${VERSION_PATCH}" |
andyfeller
commented
Oct 6, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment