|
|
You can make a shell script execute under any given shell, even if that shell is not currently running or is not the shell the script was written for, by placing on the first line of the script the special command #!shellpath, where shellpath is the absolute pathname of the shell under which the script is to execute.
For example, if your login shell is the C shell, but you want to write scripts for the Korn shell, the first line of your script should be as follows:
#!/bin/kshThis is a general mechanism: that is, shellpath does not have to be a shell, but can be any binary program. For example, awk(C) is a small programming language used for textual analysis tasks (see ``Using awk'' for an introduction to using awk). awk scripts could start with the following:
#!/usr/bin/awk -fIf the -f flag is omitted, awk will exit with an error. See exec(M) for details of this mechanism.)