Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Difference between sh and bash

  • Last Updated : 03 Nov, 2021

bash and sh are two different shells of the Unix operating system. bash is sh, but with more features and better syntax. Bash is “Bourne Again SHell”, and is an improvement of the sh (original Bourne shell). Shell scripting is scripting in any shell, whereas Bash scripting is scripting specifically for Bash. sh is a shell command-line interpreter of Unix/Unix-like operating systems. sh provides some built-in commands. bash is a superset of sh. Shell is a command-line interface to run commands ad shell scripts. Shells come in a variety of flavors, much as operating systems come in a variety of flavors. So, Shell is an interface between the user and the operating system, which helps the user to interact with the device.

sh:

#!/bin/sh

bash:

#!/bin/bash

Note:

  • Shell is an interface between the user and the operating system.
  • sh implements the shell interface.
  • bash is a superset of sh.

sh:

sh is also called Bourne Shell. sh is a command programming language described by POSIX standard. It is for UNIX or UNIX-like operating systems. It has many implementations. On most operating systems, sh is implemented by programs like dash, kash, and original Bourne Shell. sh is a Predecessor of bash. /bin/sh is an actual link to main implementations. It is a symlink in most POSIX systems.

sh is not a programming language itself. It is just a specification. sh is a detailed description of the syntax and semantics of the language. It doesn’t include an implementation. sh is written as a replacement for earlier UNIX shells. It’s most of the syntax is the same as the syntax of the ALGOL68 programming language.

We should use sh if we want our language to be compatible with multiple systems. The sh script will most like run on bash also without modifications as bash is backward compatible with sh. sh is the most portable scripting language that works on most POSIX/Unix/Linux systems. One advantage of sh is that it is guaranteed to exist on everything that purports to Unix system. 

bash:

bash is also a command programming language like sh. Nowadays, bash is a default login shell on most Linux-based operating systems. It is an extended version of the sh system for GNU replacement for the Bourne shell. We can also say bash is a programming language. Here think like python, we can start python in interactive mode and it behaves like a shell but we can also run python program on any IDE.



bash is a superset of sh. This means that bash supports features of sh and provides more functionality than sh. Although most commands do the same thing as sh. bash is not a POSIX compliant shell. It is a dialect of the POSIX shell language. Bash can run in a text window and allows the user to interpret commands to do various tasks. It has the best and most useful features of the Korn and C shells, such as directory manipulation, job control, aliases, and many others.

Like GNU software bash provides other shells, including a version of csh, Bash is the default shell. bash is intended to be a conformant implementation of the IEEE POSIX Shell and Tools portion of the IEEE POSIX specification (IEEE Standard 1003.1). Like other GNU, bash is also quite portable. This works on any Linux/Unix-based system which has bash in the expected location. bash is more functional than sh in terms of programming and interactive use.

Difference between sh and bash : 

bash

sh     

  • Bourne Again SHell
  • SHell
  • Developed by Brain Fox
  • Developed by Stephen R. Bourne
  • Successor of sh
  • Predecessor of bash
  • bash is the default SHELL
  • sh is the not default SHELL
  • #!/bin/bash
  • #!/bin/sh
  • It has more Functionality with up-gradation.
  • It has less functionality.
  • supports job controls.
  • does not support job control.
  • bash is not a valid POSIX shell.
  • sh is a valid POSIX shell.
  • Easy to use
  • not as easy as bash
  • less portable than sh.
  • more portable than bash.
  • Extended version of language
  • Original language
  • Bash scripting is scripting specifically for Bash
  • Shell scripting is scripting in any shell
  • supports command history.
  • does not supports command history.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!