Naming Standard Input (The GNU Awk User’s Guide)

From Get docs
Gawk/docs/latest/Naming-Standard-Input


2.4 Naming Standard Input

Often, you may wish to read standard input together with other files. For example, you may wish to read one file, read standard input coming from a pipe, and then read another file.

The way to name the standard input, with all versions of awk, is to use a single, standalone minus sign or dash, ‘-’. For example:

some_command | awk -f myprog.awk file1 - file2

Here, awk first reads file1, then it reads the output of some_command, and finally it reads file2.

You may also use "-" to name standard input when reading files with getline (see section Using getline from a File). And, you can even use "-" with the -f option to read program source code from standard input (see section Command-Line Options).

In addition, gawk allows you to specify the special file name /dev/stdin, both on the command line and with getline. Some other versions of awk also support this, but it is not standard. (Some operating systems provide a /dev/stdin file in the filesystem; however, gawk always processes this file name itself.)