How to use the command cowsay (with examples)

How to use the command cowsay (with examples)

Cowsay is a command-line utility that allows you to print ASCII art, with a default of a cow, saying or thinking something. It provides a fun and creative way to display text on the command line.

Use case 1: Print an ASCII cow saying “hello, world”

Code:

cowsay "hello, world"

Motivation: This use case is a simple example to showcase the basic functionality of cowsay. It demonstrates how to print an ASCII cow with a speech bubble saying the text “hello, world”.

Explanation: The command cowsay is followed by the text you want the cow to say enclosed in double quotation marks. In this case, the text is “hello, world”.

Example Output:

 ___________
< hello, world >
 -----------
     \
      \
        ....     
       ........  
      ........  
      ........  
      ....     
      ........  
      ........  
        ....     

Use case 2: Print an ASCII cow saying text from stdin

Code:

echo "hello, world" | cowsay

Motivation: This use case demonstrates how to pass a string of text from the stdin to cowsay. It is useful when you want to pass dynamically generated text to cowsay or when you have a large amount of text that is more convenient to pipe.

Explanation: The echo command is used to print the text “hello, world”. The pipe (|) symbol is used to pass the output of echo as the input to cowsay.

Example Output:

 ___________
< hello, world >
 -----------
     \
      \
        ....     
       ........  
      ........  
      ........  
      ....     
      ........  
      ........  
        ....     

Use case 3: List all available art types

Code:

cowsay -l

Motivation: This use case is useful when you want to know the available art types that you can use with cowsay. It helps to explore the different options and choose the desired art type.

Explanation: The -l option lists all the available art types that can be used with cowsay.

Example Output:

Cow files in /usr/share/cowsay/cows:
beavis.zen blowfish.cow bong bunny bussy.cow cheese cower daemon default dragon-and-cow elephant.cow elephant-in-snake eyes flaming-sheep ghostbusters-head goat.cow head-in hellokitty kiss kitty koala kosh luke-koala
mech-and-cow meow milk moofasa moose mutilated pony pony-smaller ren sheep skeleton snowman sodomized-sheep stegosaurus stimpy suse three-eyes turkey turtle.tasia unipony unipony-smaller vader vader-koala www

Use case 4: Print the specified ASCII art saying “hello, world”

Code:

cowsay -f art "hello, world"

Motivation: This use case allows you to use a custom ASCII art type while printing the text “hello, world”. It gives you the flexibility to choose from various art designs to enhance the display.

Explanation: -f art specifies the art type to be used, where “art” is the name of the ASCII art file you want to use. In this case, “art” can be replaced with the desired art file name. The text “hello, world” is enclosed in double quotation marks.

Example Output:

 ___________
< hello, world >
 -----------
     \
      \
⠰⡿⠿⠿⠿⠷⣦⣤⣤⣤⣄⡀⠀⠀⠀⣠⣶⠄⠀⠀⠀⠀⠀⢀⣠⣤⣤⣤⣀⣀⡀⠀⠀⠤⠤⠤⠶⠶⠶⠶⠶⠶.⠶⠶⠶⠾⠻⢿⣿⣿
⠘⣿⡟⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣧⣈⣉⣿⠀⠀⠀⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⡇
⠀⠸⣿⡇⢸⣿⣿⣿⣿⣿⣿⡿⠿⠟⠟⠿⢿⡄⠀⠰⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀.⠀⢀⣼⣿.⠀
⠀⠀⠸⣿⠀⠀⢿⡿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠻⠿⢿⣿⣿⣿⣿⣿⠿⠀⠀⠀⠀⠀⠀16-bit⠀⠀⠊⠁⢠⣿⡇⠀
⠀⠀⠀⠛⠿⠭⠤⠤⠤⠬⠭⢭⣭⣭⡍⠉⠲⠶⠶⠶⠶⠶⠶⠾⢿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣼⣿⡇⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⠋⠀⠸⣿⡇⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣧⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⡇⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣷⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⡇⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⠀⣼⣿⣿⡿⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠻⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⡼⢿⣿⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⢰⣳⣿⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠁⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡴⢦⣠⠞⠁⠀⠀⠀⠀⠀⡼⠏⣿⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⠟⠁⠁⠀⠀⠀⠀⠀⠀⠀⡴⠃⠀⣿⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠜⣁⣀⠀⠀⠀⠀⠀⠀⠀⡾⠀⠀⣿⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡞⠀⠀⣿⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⣿⡇⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣄⣼⣿⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠁⠀⠀⠀⠀

Use case 5: Print a dead thinking ASCII cow

Code:

cowthink -d "I'm just a cow, not a great thinker..."

Motivation: This use case demonstrates the cowthink command, which is similar to cowsay, but the cow is in a thinking posture rather than speaking. This can be used when you want the cow to appear as if it is contemplating or pondering.

Explanation: The cowthink command is followed by the text you want the cow to think, enclosed in double quotation marks. In this case, the text is “I’m just a cow, not a great thinker…”. The -d option is used to indicate the dead state of the cow.

Example Output:

 ___________
( I'm just a )
 `< cow, not  )
   ( a great   )
   ( thinker... )
   (          (__)
    ^'-----'    

Use case 6: Print an ASCII cow with custom eyes saying “hello, world”

Code:

cowsay -e characters "hello, world"

Motivation: This use case showcases the ability to customize the eyes of the ASCII cow. It allows you to choose different characters for the eyes, giving the cow a unique look or expression.

Explanation: -e characters specifies the custom eyes to be used, where “characters” is the desired eye characters you want to apply. The text “hello, world” is enclosed in double quotation marks.

Example Output:

 ___________
< hello, world >
 ----------
 \
  \
     \
      \     
       \

Conclusion:

Cowsay is a fun and whimsical command-line utility that adds a touch of creativity to the command line. With the ability to choose different ASCII art designs, custom eyes, and thought bubbles, cowsay allows users to inject some personality and amusement into their terminal experience. Whether you want a cow to say something, think, or display custom art, cowsay has you covered. Have fun experimenting with cowsay and enjoy the smiles it brings!

Related Posts

How to use the command "snap" (with examples)

How to use the command "snap" (with examples)

The snap command is used to manage the “snap” self-contained software packages, which are similar to what apt is for .

Read More
How to use the command virt-install (with examples)

How to use the command virt-install (with examples)

The virt-install command is a powerful tool used in conjunction with libvirt to create and manage virtual machines.

Read More
Changing the remote for pulling and pushing (with examples)

Changing the remote for pulling and pushing (with examples)

Use case 1: Change the upstream remote to origin git rename-remote upstream origin Motivation In this use case, we want to change the remote repository used for pulling and pushing to the new “origin” repository.

Read More