DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Automating frequent tasks

Running a script under any shell

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/ksh
This 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 -f
If the -f flag is omitted, awk will exit with an error. See exec(M) for details of this mechanism.)

Next topic: Writing a short shell script: an example
Previous topic: Creating a shell script

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005