Next: , Up: Special Files   [Contents][Index]


5.8.1 Accessing Other Open Files with gawk

Besides the /dev/stdin, /dev/stdout, and /dev/stderr special file names mentioned earlier, gawk provides syntax for accessing any other inherited open file:

/dev/fd/N

The file associated with file descriptor N. Such a file must be opened by the program initiating the awk execution (typically the shell). Unless special pains are taken in the shell from which gawk is invoked, only descriptors 0, 1, and 2 are available.

The file names /dev/stdin, /dev/stdout, and /dev/stderr are essentially aliases for /dev/fd/0, /dev/fd/1, and /dev/fd/2, respectively. However, those names are more self-explanatory.

Note that using close() on a file name of the form "/dev/fd/N", for file descriptor numbers above two, does actually close the given file descriptor.