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

Two-way inter-process communication

In Chapter 5, Printing Output in Awk, we have seen how redirection can be used to store output to a file in AWK. We also saw how a pipe is used for redirecting the output of one command to another command in AWK. Pipes use one-way communication only; they receive the output from one process and give it as input to another.

However, with GAWK, we can have two-way communication with another process. The second process here is known as a coprocess and it runs parallel to the GAWK process. The two-way communication is created using the |& operator (this operator is a borrowed feature from Korn shell (ksh)). The following is the process for creating a two-way I/O operation between processes:

{ print "data to ...

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