FreeKB - Understanding script interpreters in Linux
Understanding script interpreters in Linux

Home > Search


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.



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments