File Extension

.sh is typical (but not mandatory)

File Contents

The file should start with:


#!/bin/bash

If there is a problem with the interpreter being found type error message you can see where your systems bash interpreter is by typing "which bash" on the command line.

Blank lines are fine.

Use the # character for comments

Rules For Bash Files

Don't create the file in Widows notepad as you'll have incorrect line endings (carriage return, linefeed instead of the Unix linefeed only).  This will cause the line "#!/bin/bash" to give this error:


/bin/bash^M: bad interpreter: No such file or directory

^M is the carriage return character.   You can correct this by opening the file in Leafpad, selecting Save As and changing the Character Coding from CR+LF to LF

Things you can do

Press return to move on

#!/bin/bash

echo "Press return to start"
read dummy
echo "Ok here we go"
Pause

#!/bin/bash

echo "Starting"
sleep 1
echo "Ok here we go"

 

Problems

^M: bad interpreter: No such file or directory

See CR+LF problem in rules

Not found "/r" errors or general errors with lines that should be fine

See CR+LF problem in rules

Script won't run

Set the file permissions so its executable