Bash to Basics: Print Text with echo

In the first installment of Command Line Basics, I explained the use of the echo command. In this first installment of Bash to Basics, I’ll show how to use the echo command in a script.

Open up a text editor and paste the following text into it.


#!/bin/bash
# This is a demonstration of the echo command

echo Hello World!
echo This is my first bash program.

exit 0

Save it as a file called hello1 and exit the text editor.

We now need to make the file executable using the chmod command.

chmod +x hello1

You can now run the script program with the command

./hello1

Your output should look like

Hello World!
This is my first bash program.

Congratulations! You just wrote a shell script.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.