Contents

Introduction

A shell script is a program designed to be run by a Unix shell. Use cases for shell scripts include automating tasks and batching Unix operations.

Shebang

The first line of any shell script file should be the shebang. The shebang tells the operating system which Unix shell interpreter to use to execute the script. The shebang starts with #! followed by the path to the interpreter.

For example, if you are using the Bash shell, the shebang line would look like this:

#!/bin/bash


If you are using the Z shell, the shebang line would look like this:

#!/bin/zsh

Comments

Comments in a shell script start with the # symbol. Comments are ignored by the shell interpreter.

# this is a comment
pwd

Resources and References

For additional information about shell scripts, the following resources may be helpful:

GeeksForGeeks: Creating and Running bash and zsh Scripts

Baeldung: How to Use Command Line Arguments in a Bash Script

Red Hat: Adding arguments and options to your Bash scripts


Back to top.