Skip to content

Commit d2439dd

Browse files
Merge pull request #14 from CodeMaster7000/CodeMaster7000-patch-1
Create Compare_Versions.sh
2 parents 9cd4279 + 05ddc2d commit d2439dd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Compare_Versions.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
VERSION=$1
3+
VERSION2=$2
4+
function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; }
5+
function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; }
6+
function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; }
7+
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
8+
if version_gt $VERSION $VERSION2; then
9+
echo "$VERSION is greater than $VERSION2."
10+
fi
11+
if version_le $VERSION $VERSION2; then
12+
echo "$VERSION is less than or equal to $VERSION2."
13+
fi
14+
if version_lt $VERSION $VERSION2; then
15+
echo "$VERSION is less than $VERSION2."
16+
fi
17+
if version_ge $VERSION $VERSION2; then
18+
echo "$VERSION is greater than or equal to $VERSION2."
19+
fi

0 commit comments

Comments
 (0)