Created
March 18, 2014 11:46
-
-
Save leandroh/9618499 to your computer and use it in GitHub Desktop.
Comparacao de numeros decimais
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
# | |
# Comparacao de numeros decimais | |
# ------------------------------------------------------------ | |
# | |
# Verifica se o primeiro parametro e' maior que o segundo. | |
# | |
# Exemplo simples com retorno true/false (0/1): | |
# | |
# x=1.1.2 | |
# y=1.0.2 | |
# echo $(compare_decimal_maior $x $y) | |
# | |
# Exemplo utilizando uma estrutura condicional de um if: | |
# | |
# if [[ $(compare_decimal_maior $x $y) -eq 0 ]]; then ... fi | |
# | |
compare_decimal_maior() { | |
echo $1 $2 | awk '{ if ($1 > $2) print 0; else print 1 }' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment