ARGIND 顾名思义,就是ARG (arguments)的index
awk 'ARGIND==1{a[$1]}ARGIND==2&&($1 in a){print $0}' A B
解释
ARGIND==1 处于读取第一个参数时,hash a存储左侧第一个元素$1
ARGIND==2 处于读取第二个参数时,如果左侧第一个元素也在hash keys 中,则输出当前行
简而言之,选取AB 共同拥有的行
ARGC The number of command line arguments (does not include
options to gawk, or the program source). 命令行参数的个数
ARGIND The index in ARGV of the current file being processed. 命令行中文件序号
ARGV Array of command line arguments. The array is indexed
from 0 to ARGC - 1. Dynamically changing the contents
of ARGV can control the files used for data. 命令行参数数组
参考:
[https://blog.csdn.net/liuzhoulong/article/details/7879300]
网友评论