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
is to use a single, standalone minus sign or dash, ‘-’. For example:
some_command | awk -f myprog.awk file1 - file2
awk first reads file1, then it reads
the output of some_command, and finally it reads
You may also use
"-" to name standard input when reading
getline (see Getline/File).
gawk allows you to specify the special
file name /dev/stdin, both on the command line and
Some other versions of
awk also support this, but it
is not standard.
(Some operating systems provide a /dev/stdin file
in the file system, however,
gawk always processes
this file name itself.)