Open In App

Bash Script – Difference between Bash Script and Shell Script

In computer programming, a script is defined as a sequence of instructions that is executed by another program. A shell is a command-line interpreter of Linux which provides an interface between the user and the kernel system and executes a sequence of instructions called commands. A shell is capable of running a script. A script that is passed to a shell is known as a shell script.

Bash script:

A Bash Script is just like a simple text file, consisting of a number of commands that we usually write in a command line. In Linux file systems, they are used for doing repetitive tasks. A Bash Script may contain a number of commands, or it might contain elements like loops, functions, conditional constructs, etc. In simple words, a Bash script is a computer program that is written in the Bash programming language.



Some of the features of Bash are given below:

Example:



#!/bin/bash  

myString="GeeksforGeeks"
echo "myString: $myString"

Output:

Bash script

Shell script:

Shell is considered as a special user program that provides a platform or interface to users so that they can use operating system services. Users can provide human-readable commands to a shell and then shell convert them into kernel understandable form. A shell is considered a command language interpreter that can execute commands which can be read from input devices like a keyboard.

Some of the features of a Shell are given below:

Now a shell can accept a number of commands through a file, known as a shell script. A shell script contains a number of commands that are executed by a shell.  For example, 

Example:

#!/bin/sh

myString="GeeksforGeeks"
echo "myString: $myString"

Output:

Shell script

Table of difference between bash script and shell script

Sr. No. Bash script Shell script
01 The bash script is a script that is specifically created for Bash. The shell script is a script that can be executed in any shell. 
02 Bash scripting is a subset of shell scripting. Shell scripting is a method to automate tasks as a collection of commands. 
03 The bash script is one form of shell script. Shells may be one of  Korn, C shell, Bourne, Bash, etc.
04 Bash is an acronym for Bourne Again SHell and was developed by Brian Fox. Shell is considered the original Unix shell developed by Stephen Bourne.
05 Bash has more features as compared to Shell. Shell has fewer features as compared to Bash.
06 We can use shebang, “#!/bin/sh” if we want to use sh.  We can use shebang, “#!/bin/bash” if we want to use Bash if available. 
07 Bash is more programmer-friendly as compared to shell. Shell is less programmer-friendly as compared to Bash.
Article Tags :