What is this line in the shell script do ?#!/bin/ksh?

Showing Answers 1 - 13 of 13 Answers

Vijay

  • Jun 22nd, 2006
 

To invoke the shell indirectly this line is added as the first line in the file.This particular line invokes korn shell

soman

  • Jul 4th, 2006
 

Hi ,

I want to get good bash shell interview questions for Linux system administrator.

  Was this answer useful?  Yes

Prakash Srinivasan

  • Jul 19th, 2006
 

This line is called as "Hash Bang" Statement. This tells the OS that the particular needs the respective shell for execution. If a script file has this hash bang statement along with execution permission, then this file can be run directly without invoking thru shell command.Ex:$ instead of$ksh

the # actually is the comment which acan be used in the scripts. also // could alaso be used for the same indicating the comments. But when concerned with regards with script this ishow its is done. but its not executed anyways. The second character i.e. ! is an indication to execute any thing from the current location.For eg; if a vi editor is open and you want to run a command without exiting the editor that could be done ie.vi file1 (lets say)... the file is open now ... press the esc key then type : that is come to the commend promt type : !ls ..press enter ...you would be listing the files in the current directory.this is the purpose for the ! symbol in unix/linux shell./bin/ksh --tell that the parameters neccessary to execute the script could be found in this path.Also the specifics to be taken from the K shell i.e. the korn shell. this is because the user may be using the character specific parts of korn shell.If the line would have read some thing like this/bin/sh ...it would have taken the default shell ..in most cases the bash shellalthough this is more generic style for scriptingguys correct me if i went wrong somewhere.bye

  Was this answer useful?  Yes

Rahul

  • Mar 28th, 2007
 

It gives the environment or the shell in which your script would be run

  Was this answer useful?  Yes

ajit_saley

  • Feb 4th, 2009
 

#! line states the interpreter to be used by the shell to interpret the script.

Here, ksh interpreter is invoked for interpretation of the script.

  Was this answer useful?  Yes

my_thoughts

  • Feb 14th, 2010
 

#! at the start of the file indicates that this is a shell script file, rather than a normal file.

/bin/ksh -- runs the shell script in ksh shell.

By default the shell script runs in the current shell (usually born shell). But with the above statement the script will be run explicitly in ksh shell.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions