Tag Archives: cowsay command

Cowsay: Fun in Linux terminal

Cowsay command to have some ASCII graphics in your Linux terminal! This command displays strings of your choice as a cow is saying/thinking in graphical format.

Cowsay command!

Another article to have some fun in the Linux terminal. Previously we have seen how to create fancy ASCII banners and matrix falling code in Linux terminal. In this article we will see another small utility called cowsay which prints thinking cow ASCII picture on the terminal with a message of your choice.  Cowsay is useful to write eye-catchy messages to users in motd (message of the day)!

From the man page “Cowsay generates an ASCII picture of a cow saying something provided by the user. If run with no arguments, it accepts standard input, word-wraps the message given at about 40 columns, and prints the cow saying the given message on standard output.” That explains the functionality of cowsay. Let’s see it in action!

# cowsay I love kerneltalks.com
 ________________________
< I love kerneltalks.com >
 ------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

😀 this is how it looks in terminal! Awesome eh?

Installation is pretty simple. Install the cowsay package in your Linux and that’s it. For reference below are installation logs on my AWS EC2 Linux server.

# yum install cowsay
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos, security
Setting up Install Process
epel/metalink                                                                                                                         |  12 kB     00:00
epel                                                                                                                                  | 4.2 kB     00:00
http://mirror.math.princeton.edu/pub/epel/6/x86_64/repodata/repomd.xml: [Errno -1] repomd.xml does not match metalink for epel
Trying other mirror.
epel                                                                                                                                  | 4.3 kB     00:00
epel/primary_db                                                                                                                       | 5.9 MB     00:09
rhui-REGION-client-config-server-6                                                                                                    | 2.9 kB     00:00
rhui-REGION-rhel-server-releases                                                                                                      | 3.5 kB     00:00
rhui-REGION-rhel-server-releases-optional                                                                                             | 3.5 kB     00:00
rhui-REGION-rhel-server-rh-common                                                                                                     | 3.8 kB     00:00
Resolving Dependencies
--> Running transaction check
---> Package cowsay.noarch 0:3.03-8.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                              Arch                                 Version                                  Repository                          Size
=============================================================================================================================================================
Installing:
 cowsay                               noarch                               3.03-8.el6                               epel                                25 k

Transaction Summary
=============================================================================================================================================================
Install       1 Package(s)

Total download size: 25 k
Installed size: 31 k
Is this ok [y/N]: y
Downloading Packages:
cowsay-3.03-8.el6.noarch.rpm                                                                                                          |  25 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : cowsay-3.03-8.el6.noarch                                                                                                                  1/1
  Verifying  : cowsay-3.03-8.el6.noarch                                                                                                                  1/1

Installed:
  cowsay.noarch 0:3.03-8.el6

Complete!

Once successfully installed you can run cowsay command followed by the text you want the cow to say! There are different cow modes which you can use to change the appearance of cow 😀 (outputs later in this post)

  1. -b: borg mode
  2. -d: Cow appears dead
  3. -g: greedy mode
  4. -s: stoned cow
  5. -t: tired cow
  6. -y: Young cow 😛

Different Cowsay command examples

Normally cowsay word wraps. If you want fancy banners in cowsay you should use -n switch so that cowsay won’t word wrap and you get nice formatted output.

# figlet kerneltalks | cowsay -n
 __________________________________________________
/  _                        _ _        _ _         \
| | | _____ _ __ _ __   ___| | |_ __ _| | | _____  |
| | |/ / _ \ '__| '_ \ / _ \ | __/ _` | | |/ / __| |
| |   <  __/ |  | | | |  __/ | || (_| | |   <\__ \ |
| |_|\_\___|_|  |_| |_|\___|_|\__\__,_|_|_|\_\___/ |
\                                                  /
 --------------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||


Check out below cow appearences as listed above with different switches.

# cowsay -b kerneltalks
 _____________
< kerneltalks >
 -------------
        \   ^__^
         \  (==)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
# cowsay -d kerneltalks
 _____________
< kerneltalks >
 -------------
        \   ^__^
         \  (xx)\_______
            (__)\       )\/\
             U  ||----w |
                ||     ||
# cowsay -g kerneltalks
 _____________
< kerneltalks >
 -------------
        \   ^__^
         \  ($)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
# cowsay -s kerneltalks
 _____________
< kerneltalks >
 -------------
        \   ^__^
         \  (**)\_______
            (__)\       )\/\
             U  ||----w |
                ||     ||
# cowsay -t kerneltalks
 _____________
< kerneltalks >
 -------------
        \   ^__^
         \  (--)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
# cowsay -y kerneltalks
 _____________
< kerneltalks >
 -------------
        \   ^__^
         \  (..)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

If you observe in all different modes eyes and tongues are the only entities that change. So, you can define and change them manually too! You can define eyes with -e switch and tongue with -T switch.

# cowsay -e 88  kerneltalks
 _____________
< kerneltalks >
 -------------
        \   ^__^
         \  (88)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
# cowsay -T X kerneltalks
 _____________
< kerneltalks >
 -------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
             X ||----w |
                ||     ||

In above example I defined 88 as eyes and X as tongue!

It’s cool that developers coded so much versatility for such funny command too! Too much of switch support, man pages, and all!