Specifying a shell for a script file

When you run an executable shell script in either the Korn (the POSIX Shell) or Bourne shell, the commands in the script are carried out under the control of the current shell (the shell from which the script is started) unless you specify a different shell. When you run an executable shell script in the C shell, the commands in the script are carried out under the control of the Bourne shell (/usr/bin/bsh) unless you specify a different shell.

You can run a shell script in a specific shell by including the shell within the shell script.

To run an executable shell script under a specific shell, type #!Path on the first line of the shell script, and press Enter. The #! characters identify the file type. The Path variable specifies the path name of the shell from which to run the shell script.

For example, to run the bsh script in the Bourne shell, type the following:
#!/usr/bin/bsh

When you precede a shell script file name with a shell command, the shell specified on the command line overrides any shell specified within the script file itself. Therefore, typing ksh myfile and pressing Enter runs the file named myfile under the control of the Korn shell, even if the first line of myfile is #!/usr/bin/csh.