Bash Greetings for you script

Bash Greetings for you script

The first variable is in order to determine the logged user

The second variable is in order to determine the current hour

The third variable is in order to determine the current time with seconds.

#!/bin/bash

b=$(echo "$USER")

a=$(date +"%H")

c=$(date +"%T")

if [ "$a" -ge 6 ] && [ "$a" -lt 12 ]; then
    echo "Guten Morgen" $b "Es ist" $c
elif [ "$a" -ge 12 ] && [ "$a" -lt 18 ]; then
    echo "Guten Tag" $b "Es ist" $c
elif [ "$a" -ge 18 ] && [ "$a" -lt 20 ]; then
    echo "Guten Abend" $b "Es ist" $c
else
    echo "Gute Nacht"
fi

This is the output

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

+ 4 = 12