Next: Sample Data Files, Up: Getting Started [Contents][Index]
awk ProgramsThere are several ways to run an awk program.  If the program is
short, it is easiest to include it in the command that runs awk,
like this:
awk 'program' input-file1 input-file2 …
When the program is long, it is usually more convenient to put it in a file and run it with a command like this:
awk -f program-file input-file1 input-file2 …
This section discusses both mechanisms, along with several variations of each.
| • One-shot | Running a short throwaway awkprogram. | |
| • Read Terminal | Using no input files (input from the keyboard instead). | |
| • Long | Putting permanent awkprograms in
                                files. | |
| • Executable Scripts | Making self-contained awkprograms. | |
| • Comments | Adding documentation to gawkprograms. | |
| • Quoting | More discussion of shell quoting issues. |