Bootstrap FreeKB - Bash (Scripting) - Understanding script interpreter
Bash (Scripting) - Understanding script interpreter

Updated:   |  Bash (Scripting) articles

When viewing or creating a script, the very first line of the script will be the interpreter the script should use. In this example, the BASH interpreter is being used. 

#!/bin/bash

 

The interpreter tells Linux what language the script was written in so that the appropriate interpreter can be used when running the script. Imagine the script interpreter like a translator. You've a bunch of people speaking different languages (English, Mandarin, Spanish, Russian). Fortunately, the interpreter is really smart and understands each language.

 

Technically speaking, the #! characters are the shebang.

Following are some popular script interpreters.

  • #!/bin/sh = Legacy shell
  • #!/bin/bash = Bourne again shell
  • #!/bin/csh = C shell
  • #!/bin/ksh = Korn shell
  • #!/usr/bin/perl = Perl (.pl)
  • #!/usr/bin/python = Python (.py)

 

Each script interpreter has its own unique syntax.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 260b02 in the box below so that we can be sure you are a human.