Hello world!

The customary first program!

 

Create a new file and save as .sh file 'hello.sh'

 

Use vi as it's always available, otherwise use a good text editor that will preserve line-endings.

 

#! /bin/bash
echo "Hello, World!"

First line consists of #! (aka shebang) and path to bash /bin/bash

  1. Followed by echo and text to be echoed to the terminal within quotes "Hello, World!".

 

Next, make it executable:

chmod +x hello.sh

 

So, it can now be run:

./hello.sh

 

Sample output:

Hello, World!