Forked from bitmvr/example--parse-semver-with-bash.sh
Created
August 6, 2021 19:20
-
-
Save abdennour/34ab6441a93eb85a91b2c30056659be0 to your computer and use it in GitHub Desktop.
Parsing SemVer with Bash
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
#!/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
use can use also `` :