Translation(s): English - Italiano

(!) ?Discussion

A Shell script is a script written for and to be interpreted by a Shell. Shell scripts use ShellCommands and a specific syntax. Operations performed by shell scripts include file manipulation, program execution, and printing text.

A script is a text file, which may or may not have the file extension .sh. Other file extensions may also be used, e. g. .bash or .zsh, but this has no effect on the script’s functionality. They are just used to inform a human user about the syntax used in the script or to tell an editor program which syntax highlighting it should use.

The first line of the file begins with the so called shebang (#!) followed be the path to the shell to interpret and execute the rest of the script:

For scripts using POSIX syntax:


For scripts using Bash syntax:


The MIME type of shell scripts is nowadays text/x-shellscript but other systems may still use application/x-shellscript. As the MIME type depends on the system’s configuration, other MIME types may be used, even text/plain.

On Microsoft Windows .bat or .cmd files play a similar role but have a different syntax.