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

PROCINFO

The PROCINFO variable is an associative array containing information about the process, such as the process ID number, error number, group ID, real and effective UID numbers, and so on.

For example, if we set the FIELDWIDTHS to a certain value, then the FS will be FIELDWIDTHS. Using PROCINFO, we can print many details of the current instance of AWK program as follows:

$ vi procinfo.awkBEGIN { FIELDWIDTHS = "16"}END { printf "Process id of awk program is     : %s\n", PROCINFO["pid"];printf "User ID of user running awk is    : %s\n", PROCINFO["uid"];printf "Group ID of awk program is      : %s\n", PROCINFO["gid"];printf "Field Splitter set of awk is       : %s\n", PROCINFO["FS"];printf "Version no. of awk program is      : %s\n", PROCINFO["version"];}$ awk ...

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