Summarize shell questions in the group

Source: Internet
Author: User

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 ']

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.