Ubuntu: What exactly is a script? [duplicate]



Question:

This question already has an answer here:

I am having some difficulty understanding what a script is. As far as I understand, it's a set of commands in a shell. And what's the difference between a bash script and a shell script? can somebody explain this concept?


Solution:1

from http://en.wikipedia.org/wiki/Shell_script:

A shell script is a computer program designed to be run by the [Unix] shell, a command line interpreter. The various dialects of shell scripts are considered to be scripting languages.

In other words: a bash script is a shell script, but a shell script not necessarily a bash script.

Unlike an application, a script is usually executed as a series of commands, from A to Z (although it can run in a loop). A script hardly takes any user input once it has started and is usually written to fulfill a single job.

While modern applications usually are written in classes to fulfill a wider range of tasks, depending on what the user decides, a script mostly executes its commands from top to bottom, to exit once the job is done.

There are numerous scripting languages, of which bash is just one. To mention some which are used on Linux: python, bash, perl, awk, sed


Solution:2

The classical difference between scripts and programs is that scripts are interpreted while programs are compiled and provided in exectuable form.

The definition is blurred today as you can compile scripts if you really want (eg: PHP compiled by Facebook) and modern programming languages use interpretation at lower levels (eg: Java with JVM, .NET and IL)

Shell scripts are scripts that use the Shell Command Language (sh). sh is a specification which has multiple implementations. bash started as a sh implementation but it grew to be quite different, though it supports a sh compatibility mode.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »