I have two files, one with NF=7 and the other has NF=47
I need to check the number of occurrences of $2 in the file with NF=7. If the count is <=2, then I need to make an array from the same file containing arr1[$1]=$1
For this action I used the following code:
awk -F"," '{if(NF==7){arr[$2]++}}END{for(i in a){if(arr[i]<=2){print $0}}}'
For the action of the second file, I need to match $1 from the arr[$1]=$1 taken from the first file with $1 from the second file.
Please find below example:
File1:
1,111,,,,,,
2,111,,,,,,
3,100,,,,,,
4,111,,,,,,
File2:
1,799,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
2,899,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3,999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Output:
3,999,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,