Write a Shell Script

Your shell is what lets you command your computer to do things, bash is the language to write those commands. You can write scripts that you excute from the command line to control your computer and automate things. We'll start with a simple script.

Write Script

the script

Open the Text Editor in Ubunutu and write the script below. You'll always need #!/bin/bash at the top of your shell scripts, it tells the system what type of script this is.


# clear the screen
# make a variable with a phrase
STRING = "Fresh screen!"
# print the variable in Terminal
echo $PRINT

Now save the file somewhere, your Home directory is fine. You can give it a name like, myscript, you don't need an extension.

save file

Run Script

Next, let's make this file easy to run by changing its mode, chmod, to executable, like an app.

sudo chmod +x myscript

Now type:


Bam! It clears your Terminal screen and shows your message!

To complete this challenge, add and run this script and upload a screenshot!