Last active
February 18, 2025 16:33
-
-
Save dewomser/47d97ba9716c46e690c1c5aac6d6bd84 to your computer and use it in GitHub Desktop.
Lotto 6 aus 49 Gibt random ausgefülltes Kästchen zurück als Bashskript
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 | |
#test | |
#Copilot hat bei diesem Skript geholfen | |
# Generiere sechs zufällige Zahlen im Bereich von 1 bis 49 | |
lotto_numbers=$(shuf -i 1-49 -n 6) | |
# Sortiere die Zahlen der Reihe nach | |
sorted_numbers=$(echo $lotto_numbers | tr ' ' '\n' | sort -n) | |
# Erzeuge das Gitter | |
gitter=$(seq 49 | paste - - - - - - -) | |
# Füge die generierten Zahlen in das Gitter ein und markiere sie fett und farbig | |
echo "$gitter" | awk -v nums="$sorted_numbers" ' | |
BEGIN { | |
# Definiere die Farben | |
bold = "\033[1m"; | |
red = "\033[31m"; | |
reset = "\033[0m"; | |
split(nums, n); | |
for (i in n) { | |
num[n[i]] = 1; | |
} | |
} | |
{ | |
for (i = 1; i <= NF; i++) { | |
if ($i in num) { | |
printf " %s%s%2d%s ", bold, red, $i, reset; | |
} else { | |
printf " %2d ", $i; | |
} | |
} | |
print ""; | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Die Lottozahlen tippt diese Bsshzeile
shuf -i 1-49 -n6
Der Rest ist nur Optik