Issue
I've been writing scripts for both UNIX and Windows for almost 3 years now. I've always been confused about these two terms, for a while I thought that bash scripts were windows cmd scripts and shell scripts were UNIX scripts, but I've learned that this is not correct. So what is the difference between these two terms: BASH and Shell scripts?
Solution
"Shell script" is generic term for a script that's executed by a shell.
"Bash script" is a more specific term; it refers to a script that's executed by one specific shell, the Bash shell.
A shell is a command interpreter program. It can be used interactively (where the user types commands at a prompt, and the shell executes them), or as an interpreter for a script (where a series of commands are written in a file).
The Bourne shell is one of the older shells on UNIX (not the oldest, but we needn't worry about ancient history). Several other shells have been implemented as replacements for, or extensions of, the Bourne shell.
In particular, GNU Bash is perhaps the most commonly used shell these days. It implements the same features as the Bourne shell, plus a number of extensions.
A Bourne shell script typically starts with "Shebang" line:
#!/bin/sh
A Bash script typically starts with a Shebang that specifies the Bash shell:
#!/bin/bash
and may depend on features implemented by Bash but not by the Bourne shell.
(On some operating systems, /bin/sh
might be the same command as /bin/bash
.)
Not all Unix shells are based on the Bourne shell. In particular, csh
and its derivative tcsh
are largely incompatible with the Bourne-derived shells.
Bash has very little to do with Windows cmd
scripts, except that Bash and cmd.exe
are both command interpreters.
Answered By - Keith Thompson Answer Checked By - Pedro (WPSolving Volunteer)