Executable Scripts (The GNU Awk User’s Guide)
Next: Comments, Previous: Long, Up: Running gawk [Contents][Index]
1.1.4 Executable awk Programs
Once you have learned awk, you may want to write self-contained awk scripts, using the ‘#!’ script mechanism. You can do this on many systems.8 For example, you could update the file advice to look like this:
#! /bin/awk -f
BEGIN { print "Don't Panic!" }
After making this file executable (with the chmod utility), simply type ‘advice’ at the shell and the system arranges to run awk as if you had typed ‘awk -f advice’:
$ chmod +x advice $ ./advice -| Don't Panic!
Self-contained awk scripts are useful when you want to write a program that users can invoke without their having to know that the program is written in awk.
|
Understanding ‘
The line beginning with ‘ Some systems limit the length of the interpreter name to 32 characters. Often, this can be dealt with by using a symbolic link. You should not put more than one argument on the ‘
Finally, the value of |
Footnotes
(8)
The ‘#!’ mechanism works on GNU/Linux systems, BSD-based systems, and commercial Unix systems.
Next: Comments, Previous: Long, Up: Running gawk [Contents][Index]