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.
Further Reading
- The Linux Command Line by William Shotts
- Shell Scripting by Jason Cannon
- Mastering Linux Shell Scripting by Mokhtar Ebrahim, Andrew Mallett
- Bash Cookbook by Carl Albing, J.P. Vossen
- Wicked Cool Shell Scripts by Dave Taylor, Brandon Perry
- Black Hat Bash by Nick Aleks, Dolev Farhi
- Bash Pocket Reference by Arnold Robbins
- Learning the Bash Shell by Cameron Newham
- Linux Command Line and Shell Scripting Bible by Richard Blum, Christine Bresnahan