Skip to content

To write a simple shell script to print “Hello Shell Scripting” in the terminal.

Steps:
Create a shell-scripts folder inside workspace folder in your home folder. This is just to keep all your project files organized.

mkdir -p ~/workspace/shell-scripts

Go inside the shell-scripts folder.

cd ~/workspace/shell-scripts

Inside this folder create a file called hello.sh.

touch hello.sh

Open this file in a text-editor

gedit hello.sh

If you have Sublime-Text installed, you can use-

subl hello.sh

Now write the shebang for the script.

#!/bin/bash

Below it write the command to print “Hello Shell Scripting” in the terminal.

echo Hello World

Now save the file and close the text-editor.

Use chmod to make this script an executable.

sudo chmod +x hello.sh

Run the script.

./hello.sh

If done correctly you should see the following output in the terminal-

Hello Shell Scripting

Code

#!/bin/bash
echo Hello World