Shell script basicsΒΆ

A shell is the layer between you and the unix operating system, and provides easy access to unix commands. If you are new to shell programming, please read How do I write a shell script?.
Popular basic text editors include ‘gedit’ (graphical interface), and ‘nano’ (curses-based interface). More advanced editors include ‘vi’ and ‘emacs’.

Example

Below is an example of a simple shell script that prints the date, and then sleeps 20 seconds.

  1. Start a text editor:

    $ nano
  2. Enter the following text, and save as ‘simple.sh’:

    #!/bin/sh
    date
    sleep 20
  3. Make the script executable:

    $ chmod a+x simple.sh
  4. Run the command at the shell prompt:

    $ ./simple.sh