Jump to content
Sign in to follow this  

[Invisionize.eu] Master_Odin's Blog - cowsay and fortune on terminal start-up

Recommended Posts

My friend, after having some problems with his Ubuntu boot, decided to install and use Mint. Now, fast forward and month or two, and it turns out he has this thing where whenever he opens terminal, he gets a random quote (fortune) with a random animal saying it (cowsay).

To get this simple effect, you'd open /etc/bash.bashrc by running:

gksudo gedit /etc/bash.bashrc

and the add the following at the end of the file:

/usr/games/fortune -a | cowsay

of course, this gives you only a cow, and not just any animal. So to get that "random animal" effect, I had to develop a way to grab the filename of a file within the directory /usr/share/cowsay/cows/. I accomplished this using a bit of trusty ol' sed and my end result is as follows:


file=`/bin/ls -1 "$dir" | sort --random-sort | head -1`

cow=$(echo "$file" | sed -e "s/\.cow//")

/usr/games/fortune -a | cowsay -f $cow

You'll now get a random animal saying a random fortune (pulled from all databases). Enjoy.

Zobacz Artykuł w pełnej wersji

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...

Important Information

W celu świadczenie usług przez nasz Serwis na najwyższym poziomie, w ramach Serwisu wykorzystujemy pliki Cookies (tzw. ciasteczka). Korzystając ze stron Serwisu IPSBEYOND.PL bez zmiany ustawień przeglądarki będą one zapisane w pamięci urządzenia. Jeżeli nie dokonacie Państwo zmiany ustawień przeglądarki internetowej to wyrażacie zgodę na zapisywanie plików Cookies.