Cow Fortunes

Unicows

ImageI was bored and made my server have a cow tell me a fortune when I log in.

In this instance there are two places you can add the lines below, /etc/bash.bashrc for all users and /home/username/.bashrc for the specified user.

if [ -x /usr/games/cowsay -a -x /usr/games/fortune ]; then
fortune | cowsay
fi

ImageCowsay also has unicorn ponies.

Explanation of the snippet:

-x and -a are conditions for the if statement. -x returns true if the file exists and is executable. -a returns true if the file exists.

fortune displays a random fortune from a default pool

cowsay displays input in a cow’s speech bubble

|  pipes the output from one command to another

This translates to:

If cowsay and fortune both exist then use the output of fortune as the input into cowsay.

View original post

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s