File
22924 183.136.221.76 200
20747 119.146.204.15 200
19563 61.182.133.37 200
19150 112.85.218.29 200
18002 113.106.128.3 200
123 113.106.128.3 200
File B
113.106.128.3
1.1.1.1
61.182.133.37
Ladies and gentlemen, how can we print out all the records of file a $2 equal to file B $1?
Awk 'fnr = nR {A [$0]} Nr> FNR {if ($2 in A) print} 'B
Of course there are some answers from the experts:
Grep-f B
For more information, see man grep.
But someone answered this question for the first time:
awk '{A [$2] = $2} Nr> FNR {if (a [$1] ++) print} 'a B Indicates finding the same part of A and B
Python problem: 0123456789 abcdef, in python, how to split each two into a group of answers: Echo 0123456789abcdef | sed-r's /.. /&,/g; S/^ (. *), $/\ [\ 1 \]/'[, 23, 45, 67, 89, AB, CD, EF] >>> [s [I: I + 2] For I in range (0, Len (s), 2)] ['01', '23', '45', '67', '89 ', 'AB', 'cd', 'ef '] A = [0123456789 abcdef] I = 0 while A: I + = 2a [0], A [1] A = A [I:] >>> re. subn (R '(..) ',' \ 1, ', S) [0]. split (',') [:-1] ['01', '23', '45', '67', '89 ',' AB ', 'cd ', 'ef ']