sh Command: Tutorial & Examples

Launch the Bourne shell

The sh command is a command-line utility that launches the Bourne shell. The Bourne shell is a command-line interpreter for Unix-based systems, and it is one of the most commonly used shells in Linux and other Unix-like operating systems.

Here are some examples of using the sh command:

To launch the Bourne shell and start an interactive session, use the command:

sh

To run a shell script, use the command:

sh script.sh

To run a shell script with arguments, use the command:

sh script.sh arg1 arg2

To run a shell script and redirect input and output to a file, use the command:

sh script.sh < input.txt > output.txt

The Bourne shell is a powerful command-line interpreter and provides many features such as command line editing, command history, and environment variables. It is also the foundation of other shells such as the Bourne Again Shell (bash) and the Korn shell (ksh).

It's worth noting that the sh command is typically a symlink to another shell such as bash on modern Linux distributions, and not the original Bourne shell. In some cases, the original Bourne shell is not even installed on the system.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA