Here's a solution that doesn't require fudging with SUBSEP, looping through the fields, having the files being pre-sorted, or have a pre-set number of columns/fields :
mawk -v \_=testfile_001.txt -F/ ' BEGIN { while(getline<_) { __[$!(NF=NF)] } _=close_*=close(_)*(FS="^$") } _^($_ in __)' testfile_002.txt 0 14 0 15 0 20 7200 14 7200 15 - just realized setting
FS="^$"for 2nd file is much faster since we're doing line-wide matching, sosplitting fieldsis a waste of time.
Tested and proven working on gawk 5.1.1 (including flags -c/-P), mawk 1.3.4, mawk 1.9.9.6, and macos nawk
-- The 4Chan Teller