Copyright (C) 2000-2012 |
GNU Info (gawk.info)LongRunning Long Programs --------------------- Sometimes your `awk' programs can be very long. In this case, it is more convenient to put the program into a separate file. In order to tell `awk' to use that file for its program, you type: awk -f SOURCE-FILE INPUT-FILE1 INPUT-FILE2 ... The `-f' instructs the `awk' utility to get the `awk' program from the file SOURCE-FILE. Any file name can be used for SOURCE-FILE. For example, you could put the program: BEGIN { print "Don't Panic!" } into the file `advice'. Then this command: awk -f advice does the same thing as this one: awk "BEGIN { print \"Don't Panic!\" }" This was explained earlier (*note Running `awk' Without Input Files: Read Terminal.). Note that you don't usually need single quotes around the file name that you specify with `-f', because most file names don't contain any of the shell's special characters. Notice that in `advice', the `awk' program did not have single quotes around it. The quotes are only needed for programs that are provided on the `awk' command line. If you want to identify your `awk' program files clearly as such, you can add the extension `.awk' to the file name. This doesn't affect the execution of the `awk' program but it does make "housekeeping" easier. automatically generated by info2www version 1.2.2.9 |