Use the Linux cowsay command for a colorful holiday greeting | Opensource.com

Use the Linux cowsay command for a colorful holiday greeting

Celebrate the Day of the Dead using this fun Linux command-line tool.

Pumpkins painted for Day of the Dead
Image credits : 

Photo by Drew Hays on Unsplash

x

Subscribe now

Get the highlights in your inbox every week.

You may have heard of a small program that takes input, such as a message that you type, and outputs a picture of a cow quoting your message. It is called cowsay. It has been written about before here on Opensource.com.

So, to have a little fun with it, I thought I'd use it to celebrate Día de los Muertos (Day of the Dead).

In addition to a cow, there are other images available. When you install cowsay it includes several other images, which the install stores in /user/share/cowsay. You can use the -l argument to get a list.

$ sudo dnf install cowsay
$ cowsay -l

There's actually quite a bit of development activity related to cowsay and similar programs. It is possible to create your own image files or download images others have made. For instance, Charc0al's cowsay file converter is located on GitHub. You can use this tool to convert your own pictures to the special ASCII format file required by cowsay. Depending on your Linux or FreeBSD terminal settings, you may have color support enabled. The cowsay utility can display color images, as well. Charc0al's converter provides many ready-to-go color files.

I chose to use the Beetlejuice file for my celebration. First, I saved the beetlejuice.cow file to /usr/share/cowsay. This directory is owned by root, so you may have to save the file to your home directory first and then copy it. I also needed to give all users read access.

$ sudo cp beetlejuice.cow /usr/share/cowsay
$ sudo chmod o+r /usr/share/cowsay/beetlejuice.cow

It is interesting to notice how the image is generated. The top sets various ASCII color control codes to variables. These variables are then used to draw the image in the traditional ASCII art style. The image is almost full-body and did not fit my terminal height without scrolling off the screen, so I edited the file and removed the last 15 lines to shorten it.

The image is also detected by the cowsay program and appears in the list.

$ cowsay -l
Cow files in /usr/share/cowsay:
beavis.zen beetlejuice blowfish bud-frogs bunny cheese cower default dragon
...

Now, simply run the program and specify the image using the -f option. Don't forget to provide a message.

$ cowsay -f beetlejuice "Happy Day of the Dead!"

cowsay_beetlejuice.png

ASCII display of Beetlejuice via cowsay

Beetlejuice says Happy Day of the Dead  (CC BY-SA 4.0)

The cowsay command is just another way to have some command-line fun with your Linux computer. Experiment with cowsay and ASCII art—get creative.

Linux toy: cowsay

Bring a bovine voice to your terminal output with the cowsay utility.
Happy Halloween ASCII art on FreeDOS

Generate colorful ASCII art from a C program using either Linux or FreeDOS.
Full moon on a hazy night

To kill a zombie process, you must remove its name from the process list.

About the author

Alan Formy-Duval Opensource.com Correspondent
Alan Formy-Duval - Alan has 20 years of IT experience, mostly in the Government and Financial sectors. He started as a Value Added Reseller before moving into Systems Engineering. Alan's background is in high-availability clustered apps. He wrote the 'Users and Groups' and 'Apache and the Web Stack' chapters in the Oracle Press/McGraw Hill 'Oracle Solaris 11 System Administration' book. He earned his Master of Science in Information Systems from George Mason University. Alan is a long-time proponent of Open...