Running gawk (The GNU Awk User’s Guide)

From Get docs
Gawk/docs/latest/Running-gawk


1.1 How to Run awk Programs

There 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 awk program.
Read Terminal    Using no input files (input from the keyboard instead).
Long    Putting permanent awk programs in files.
Executable Scripts    Making self-contained awk programs.
Comments    Adding documentation to gawk programs.
Quoting    More discussion of shell quoting issues.