Skip to content

Commit

Permalink
get/vint for version string comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
briceburg committed May 23, 2017
1 parent e70c768 commit c878a11
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,14 @@ get/gid_from_name(){
get/gid_from_path(){
ls -ldn "$1" 2>/dev/null | awk '{print $4}'
}


# usage: get/int_from_version <version string>
# returns a comparable interger from a version string e.g.
# "2" => 2000000000000
# "2.0" => 2000000000000
# "2.0.33" => 2000000330000
# "2.0.33.121" => 2000000330121
get/vint(){
echo "$@" | awk -F. '{ printf("%d%04d%04d%04d\n", $1,$2,$3,$4); }';
}

0 comments on commit c878a11

Please sign in to comment.