Bash Shell Echo Command Tutorial

In the previous tutorial on introduction to bash shell, we got a general idea on what are shell scripts and how to execute them. In this part of the tutorial, we are going to see how to print the message on to the terminal using an echo command.

Terminal is a interactive tool to interact with the shell environment.To print we use a command called echo command. Echo is the basic command for printing on the terminal.So let`s understand echo command in detail.

To print any statement in terminal using the echo command: You can add the statement within the double quotes:

[root@localhost sysadminscripts]# echo "Bash Shell Tutorial"
Bash Shell Tutorial

So echo space double quote (starts here) statement double quote (ends here).

If you do not put the statement between the double quotes, it still going to print your statement:

[root@localhost sysadminscripts]# echo Bash Shell Tutorial
Bash Shell Tutorial

However, single quotes have their own purpose. Let`s say I want to print a statement on the terminal.

Bash Shell Tutorial !!!

Here instead of a simple statement we have three exclamation sign as well. So if we try to print it within double quote. We will see an error:

[root@localhost sysadminscripts]# echo "Bash Shell Tutorial !!!"
-bash: !": event not found

But if you put the same statement with exclamation sign within single quote. It is going to work:

[root@localhost sysadminscripts]# echo 'Bash Shell Tutorial !!!'
Bash Shell Tutorial!!!

So this tutorial gives you a general idea on how to print a statement on a terminal, what`s a terminal and what is an echo command and how to use it.

© 2010 ToGoTutor | Copyright | Privacy Policy | |Subscribe to togotutor.com newsfeed|