May 2000
Beginner
761 pages
18h 20m
English
If you plan to use a file or pipe in an awk program again for reading or writing, you may want to close it first, because it remains open until the script ends. Once opened, the pipe remains opened until awk exits. Therefore, statements in the END block will also be affected by the pipe. The first line in the END block closes the pipe.
(In Script) 1 { print $1, $2, $3 | " sort -r +1 -2 +0 -1"} END{ 2 close("sort –r +1 –2 +0 –1") <rest of statements> } |
Explanation
Awk pipes each line from the input file to the UNIX sort utility.
When the END block is reached, the pipe is closed. The string enclosed in double quotes must be identical to the pipe string where the pipe was initially opened.
Read now
Unlock full access