What is a Bash script?

Bash is a type of interpreter that processes shell commands. A command is given in the form of plain text that calls operating system services to perform a task.

Commands like ls or cd are frequently used by programmers; these commands are written in the terminal. The terminal acts as an interface for the shell interpreter.

A Bash script is a text file containing a series of commands.

Any command that can be executed in the terminal can be put into a Bash script. Any series of commands to be executed in the terminal can be written in a text file, in that order, as a Bash script.

Bash scripts are given an extension of .sh.

Let’s just say we have a Bash script, bash_intro.sh, consisting of the following commands:

cd DRP/
ls

In order to run the above Bash script, run the following command in the terminal:

bash bash_intro.sh

The shell will start executing the commands in the script in sequence; it will navigate to the DRP folder and then list its contents down in the terminal. See the output below:

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved