March 2018
Beginner to intermediate
416 pages
9h 24m
English
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 ...
Read now
Unlock full access