Last active
August 29, 2015 13:58
-
-
Save ManasJayanth/10344552 to your computer and use it in GitHub Desktop.
Bash script to limit the number of times fortune-cowsay message is displayed at terminal start up
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
# Checking dependencies | |
command -v fortune >/dev/null 2>&1 || | |
{ echo >&2 "I require fortune but it's not installed. Aborting."; exit 1; } | |
command -v cowsay >/dev/null 2>&1 || | |
{ echo >&2 "I require cowsay too, but it's not installed. Aborting."; exit 1; } | |
# Set your counter limit here | |
COUNTER_LIMIT=7 | |
FILE="$HOME/.counter.data" | |
if [ ! -f $FILE ] | |
then | |
echo 0 > $FILE | |
fi | |
count=`cat $FILE` | |
if [ $(($count % $COUNTER_LIMIT)) == 0 ] | |
then | |
fortune | cowsay | |
fi | |
count=`expr $count + 1` | |
echo $count > $FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the number should be random, it is more surprising when it appears when u least expect it. :).