Skip to content

Instantly share code, notes, and snippets.

@shellscriptx
Created March 4, 2018 20:04
Show Gist options
  • Save shellscriptx/413dd9975bfa39624e70dcca47461ad6 to your computer and use it in GitHub Desktop.
Save shellscriptx/413dd9975bfa39624e70dcca47461ad6 to your computer and use it in GitHub Desktop.
[BAHSRC] Somando e triplicando valores distintos em uma expressão.
#!/bin/bash
source builtin.sh
source regex.sh
st_par_impar()
{
# par - +10
# impar - *3
[[ $(($1%2)) == 0 ]] && echo $(($1+10)) || echo $(($1*3))
}
# 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 st_par_impar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment