DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(gawk) One-shot

Info Catalog (gawk) Running gawk (gawk) Running gawk (gawk) Read Terminal
 
 One-shot Throw-away `awk' Programs
 ----------------------------------
 
    Once you are familiar with `awk', you will often type in simple
 programs the moment you want to use them.  Then you can write the
 program as the first argument of the `awk' command, like this:
 
      awk 'PROGRAM' INPUT-FILE1 INPUT-FILE2 ...
 
 where PROGRAM consists of a series of PATTERNS and ACTIONS, as
 described earlier.
 
    This command format instructs the "shell", or command interpreter,
 to start `awk' and use the PROGRAM to process records in the input
 file(s).  There are single quotes around PROGRAM so that the shell
 doesn't interpret any `awk' characters as special shell characters.
 They also cause the shell to treat all of PROGRAM as a single argument
 for `awk' and allow PROGRAM to be more than one line long.
 
    This format is also useful for running short or medium-sized `awk'
 programs from shell scripts, because it avoids the need for a separate
 file for the `awk' program.  A self-contained shell script is more
 reliable since there are no other files to misplace.
 
     Useful One Line Programs One-liners, presents several short,
 self-contained programs.
 
    As an interesting side point, the command
 
      awk '/foo/' FILES ...
 
 is essentially the same as
 
      egrep foo FILES ...
 
Info Catalog (gawk) Running gawk (gawk) Running gawk (gawk) Read Terminal
automatically generated byinfo2html