awk's arrays are basically hashes/associative arrays, so you can just use the frequencies as keys much like the Python dictionary solutions. Because awk is really focused on processing a list of files, this uses a hack on the built-in variable that tracks where on that list awk has gotten to, so it only stops once it's found the duplicate.
BEGIN{f=0a[0]=1}{f+=$1if(fina){a[f]+=1}else{a[f]=1}if(a[f]==2){print(f)exit0}# Resets what file is the next to processARGIND=0}
awk -f 1.2.awk 1.2.input
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This seemed easiest to do in
awk
:Part 1
Part 2
awk
's arrays are basically hashes/associative arrays, so you can just use the frequencies as keys much like the Python dictionary solutions. Becauseawk
is really focused on processing a list of files, this uses a hack on the built-in variable that tracks where on that listawk
has gotten to, so it only stops once it's found the duplicate.