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

ARGIND

ARGIND represents the index in the ARGV array to retrieve the current file being processed. When we operate with one file in AWK script, the ARGIND will be 1, and ARGV[ARGIND] will return the filename that is currently being processed.

In the following example, we print the value of ARGIND and the current filename using ARGV[ARGIND] as follows:

$ vi argind.awkEND    {    print "ARGIND : ", ARGIND;    print "Current Filename : ", ARGV[ARGIND];
}$ awk -f argind.awk

The output of the execution of the preceding code is as follows:

ARGIND :  1Current Filename :  cars.dat

We have printed the value stored in ARGIND in the END block here so that it is not printed in a loop when each line of cars.dat is processed. So, we can say that the value stored ...

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