Forked from bitmvr/example--parse-semver-with-bash.sh
Created
December 16, 2021 16:09
-
-
Save benjaminapetersen/d0b0758dfc84a1fff73987fed75ce895 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}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment