Skip to content

Instantly share code, notes, and snippets.

@alicraigmile
Last active May 23, 2021 21:54
Show Gist options
  • Save alicraigmile/cc83201e07ddc8472765 to your computer and use it in GitHub Desktop.
Save alicraigmile/cc83201e07ddc8472765 to your computer and use it in GitHub Desktop.
Say hello to me.
#!/bin/bash
#Source: https://gist.github.com/alicraigmile/cc83201e07ddc8472765
function welcome() {
HOUR=$(date +%H)
HOUR=$(expr $HOUR + 0) #fix for leading zeros
NAME=$(finger $USER |head -n1 |cut -d : -f3 | sed -e 's/^ *//' | cut -d ' ' -f1) #firstname (remove last 'cut' for full name)
if [[ $HOUR -lt 5 ]]; then
echo "Go to bed, $NAME!";
elif [[ $HOUR -lt 12 ]]; then
echo "Welcome, $NAME. Good morning.";
elif [[ $HOUR -lt 17 ]]; then
echo "Welcome, $NAME. Good afternoon.";
else
echo "Welcome, $NAME. Good evening.";
fi
}
welcome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment