Last active
March 4, 2018 19:45
-
-
Save shellscriptx/1da0fb0234c4a019cb95a23b146373b5 to your computer and use it in GitHub Desktop.
[BASHSRC] Dobrar determinados números contidos na expressão.
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
#!/bin/bash | |
source builtin.sh | |
source regex.sh | |
dobrar_cond() | |
{ | |
# Dobra somente os números maiores que '30' | |
[[ $1 -gt 30 ]] && echo $(($1*2)) || echo $1 | |
} | |
# Valores | |
chaves='valor: 10, valor: 15, valor: 20, valor: 25, valor: 30, valor: 35, valor: 40, valor: 45, valor: 50' | |
# Aplica as substituições. | |
regex.fnreplace '[0-9]+' "$chaves" -1 $REG_CASE dobrar_cond |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment