SemVer Commands
Semantic Versioning and version ranges.All SemVer pages
- Bump a semantic version number from the command line (major, minor, patch, prerelease)Increment a version with npx semver -i (major, minor, patch, premajor, prerelease, release) or npm version, with pre-release ids and the main edge cases.
- Compare two version numbers in bash (is version A greater than B?)Compare version numbers in a bash script with sort -V -C, npx semver or Python semver; why string comparison fails and how pre-release versions differ.
- Sort version numbers correctly: sort -V vs semverPlain sort puts 1.10.0 before 1.9.3. sort -V orders numbers correctly but misplaces pre-releases; npx semver sorts by SemVer rules and filters by ranges.
- Validate a semantic version string with a regex (bash, grep, Python)Check that a string is a valid SemVer 2.0.0 version with the official semver.org regex in bash, grep -E and Python, and extract major, minor and patch.