Starting Basics for running a bash script

First of all you need to open the terminal [Ctrl + Alt + T] OR Konsole [for kubuntu]

Type in “pwd” to get the present working directory.

Then use cd to change the directory location to the location of your script.


For example:


I have changed the directory to Desktop/test/ because my script lies inside test folder.

So, as now we are in the directory which contains our script file we need to edit it and write something inside it.

As the beginning program, we start with echo command.

Contents of my


Now to run this script, we first need to give execute permissions to our script, for that we need to type the following command in terminal:

Now in order to run it, type in terminal:

And you will get the output as:

which was the expected output as echo prints the things you write inside it.


More about echo:

Echo can be used in 3 ways:

However, both 3 of them the output will vary!

For example:

I set a variable named test=”Blogging”

Now for all the 3 types:


Output for the above statements:


As you can see while using single quotes we are unable to print the variable value.


1 more thing is to be kept in mind while using echo without any quotes that if we want to use special symbols we need to add an escaping character infront of it in order to get it printed without getting error.

For example:

will run without any problem when we use \ as escaping character.


Check out the next post to continue learning bash scripting.

Hope you have a good day! 🙂