gawk: One-shot

1 
1 1.1.1 One-Shot Throwaway 'awk' Programs
1 ---------------------------------------
1 
1 Once you are familiar with 'awk', you will often type in simple programs
1 the moment you want to use them.  Then you can write the program as the
1 first argument of the 'awk' command, like this:
1 
1      awk 'PROGRAM' INPUT-FILE1 INPUT-FILE2 ...
1 
1 where PROGRAM consists of a series of patterns and actions, as described
1 earlier.
1 
1    This command format instructs the "shell", or command interpreter, to
1 start 'awk' and use the PROGRAM to process records in the input file(s).
1 There are single quotes around PROGRAM so the shell won't interpret any
1 'awk' characters as special shell characters.  The quotes also cause the
1 shell to treat all of PROGRAM as a single argument for 'awk', and allow
1 PROGRAM to be more than one line long.
1 
1    This format is also useful for running short or medium-sized 'awk'
1 programs from shell scripts, because it avoids the need for a separate
1 file for the 'awk' program.  A self-contained shell script is more
1 reliable because there are no other files to misplace.
1 
1    Later in this chapter, in ⇒Very Simple, we'll see examples of
1 several short, self-contained programs.
1