Coding a Tribute to Nyan Cat in Bash

Here’s a fun guided project to get familiar with looping and colors and clearing the terminal in Bash.

But First …

Keep in mind that this will only work from a true Bash command line.

Step by Step

You’ll probably want to put this in your codebook so let’s navigate there.

cd repos/codebook

Now let’s make a file for our Bash script.

touch nyan

Now we need to turn this simple file into a script that can be executed. We will use the chmod +x command. But first let’s look at the plain file before we change it.

ls -l nyan
-rw-r--r-- 1 rob rob 0 Apr 29 17:55 nyan

Notice the rw and r. These mean that the file is readable and writable by different people. The first set is for the owner rob in this case. The second set is the group rob and the third are for everyone else also known as other or world.

Now let’s change it and see what happens.

chmod +x nyan
ls -l nyan
-rwxr-xr-x 1 rob rob 0 Apr 29 17:56 nyan

Notice the xs that were added. This means that the file is now considered an executable script.

Now we can put our coding instructions into it and run it to make them happen.