O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Special file for redirecting output (/dev/null, stderr)

Linux/Unix programs use three streams available to them for reading input and writing output, named standard input, standard output, and standard error. These open streams (open files or pipes) are known as file descriptors. By default, these streams are connected to a keyboard for input and a screen for output. There are the two different ways of writing an error message to standard error in AWK programs.

In the following example, error message is first send to another shell process cat using pipe, which further send it to standard error stream using file descriptors ( 1  and 2 ) as follows :

$ awk 'BEGIN{ print "Error message!" | "cat 1>&2" }'

The output on execution of the preceding ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required