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
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.