Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: What is 1st line(#!/bin/sh) in shell script?  (Read 1271 times)

0 Members and 1 Guest are viewing this topic.

aravindm

  • Guest
What is 1st line(#!/bin/sh) in shell script?
« on: March 03, 2018, 04:56:47 pm »
The sha-bang ( #!) at the head of a script tells the system that this file is a set of commands to be fed to the command interpreter defined by the path-name. The #! is a two-byte magic number, a special marker that defines a file type.

Closely following the sha-bang is a path name - this is the path to the program that interprets the commands in the script, whether it be a shell, a programming language, or a utility. This command interpreter then executes the commands in the script, starting at the top (the line following the sha-bang line), and ignoring comments.

You can only leave out of #!, if the script consists only of a set of standard system commands, using no internal shell directives or builtins/functions. ;)