awk ARGV, ARGC - Array of Command Line Arguments


Example

Command line arguments passed to awk are stored in the internal array ARGV of ARGC elements. The first element of the array is the program name. For example:

awk 'BEGIN {
   for (i = 0; i < ARGC; ++i) {
      printf "ARGV[%d]=\"%s\"\n", i, ARGV[i]
   }
}' arg1 arg2 arg3

produces:

ARGV[0]="awk"
ARGV[1]="arg1"
ARGV[2]="arg2"
ARGV[3]="arg3"