Skip to content

Instantly share code, notes, and snippets.

@DiscowZombie
Created December 20, 2018 09:53
Show Gist options
  • Select an option

  • Save DiscowZombie/9effe792162bcdd7376a225fed705dca to your computer and use it in GitHub Desktop.

Select an option

Save DiscowZombie/9effe792162bcdd7376a225fed705dca to your computer and use it in GitHub Desktop.
Bash revision
#!/bin/bash
# Entier entre [10;100[
if [[ "$1" =~ ^([0-9]){2}$ ]]; then
# Afficher tous les nombres de 0 inclus au premier paramètre exclus
for (( i=0; i < $1; i++ )); do
echo $i
done
# Un nombre entier
elif [[ "$1" =~ ^([0-9])+$ ]]; then
i=$1
counter=0
# Tant que la condition n'est pas satisfaite, faire...
until [ $i -lt 0 ]; do
i=$((i-=1))
counter=$((counter + 1))
done
# Compter le nombre d'éxecutions
echo "I reach the end after $counter execution."
# Une chaîne de caractères
else
# Afficher la chaîne
for c in "$1"
do
echo -e "$c\n"
done
fi
#!/bin/bash
print_fct () {
echo "Simple function with print"
}
loc_var () {
local var="This is a cool message"
echo "Local : $var"
echo "Passed param : $1"
return 2
}
print_fct
loc_var "bonjour"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment