Skip to content

Instantly share code, notes, and snippets.

@bmcculley
Last active January 10, 2022 00:34
Show Gist options
  • Save bmcculley/ec2323d8132290dcb7b8 to your computer and use it in GitHub Desktop.
Save bmcculley/ec2323d8132290dcb7b8 to your computer and use it in GitHub Desktop.
A handy shell script to use as a starting point if you need to setup something that only fires on x days of the week.
#!/bin/bash
###############################################################################
# A handy starting point if you need to setup something that only fires on x #
# days of the week. #
###############################################################################
DAYNUM=$(date +"%u")
if [ $DAYNUM -eq 1 ]; then
echo "It's Monday"
elif [ $DAYNUM -eq 2 ]; then
echo "It's Tuesday"
elif [ $DAYNUM -eq 3 ]; then
echo "It's Wednesday"
elif [ $DAYNUM -eq 4 ]; then
echo "It's Thursday"
elif [ $DAYNUM -eq 5 ]; then
echo "It's Friday"
elif [ $DAYNUM -eq 6 ]; then
echo "It's Saturday"
elif [ $DAYNUM -eq 7 ]; then
echo "It's Sunday"
else
echo "I have no idea"
fi
#!/bin/bash
###############################################################################
# A handy starting point if you need to setup something that only fires on x #
# days of the week. #
###############################################################################
DAYNUM=$(date +"%u")
if [ $DAYNUM -eq 1 ]; then
echo "It's Monday"
elif [ $DAYNUM -eq 2 ]; then
echo "It's Tuesday"
elif [ $DAYNUM -eq 3 ]; then
echo "It's Wednesday"
elif [ $DAYNUM -eq 4 ]; then
echo "It's Thursday"
elif [ $DAYNUM -eq 5 ]; then
echo "It's Friday"
elif [ $DAYNUM -eq 6 ] || [ $DAYNUM -eq 7 ]; then
echo "It's the weekend!"
else
echo "I have no idea"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment