Finding intersection


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding intersection
# 1  
Old 05-15-2012
Finding intersection

Hi Friends,

I would like to be helped for the following issue I am currently stuck with

I have two files like the following

Code:
tom ram 10 20
hey bye 11 12
bus cat 20 30
put but 25 30

Code:
jak mok 11 12
fil don 76 57
bus cat 23 45
pan ban 09 78
put but 45 67
kis mis 23 45

I would like to find the common records between these two files
So, the o/p would be

Code:
bus cat 20 30 23 45
put but 25 30 45 67

# 2  
Old 05-15-2012
You already posted very similar problem 5 days ago: https://www.unix.com/shell-programmin...n-records.html The solution that I gave you there is working without any changes...
This User Gave Thanks to bartus11 For This Post:
# 3  
Old 05-15-2012
Hey Bartus,

Sorry, I totally lost my mind somewhere.

Thanks for reminding that I have posted it already.

Wil check it out. Hate my laziness SmilieSmilieSmilieSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Intersection by part of the string

Hi, I like to intersect two files based on their first columns. Here is the code which does the trick for me: awk 'NR==FNR{A;next}$1 in A' file1 file2 However, this only looks for exact matches between the two files in the first column. I need them to be printed even if part of the string... (10 Replies)
Discussion started by: a_bahreini
10 Replies

2. UNIX for Dummies Questions & Answers

Intersection by specific columns

Hi, I'd like to intersect two files by the 4th col of the first file and 6th col of the second file. This is the code I use: awk 'NR==FNR{A;next}$6 File1 File2 However, this is only outputting the second file lines. I'd like to have both lines in a single line separated by a tab. Thanks in... (25 Replies)
Discussion started by: a_bahreini
25 Replies

3. Shell Programming and Scripting

finding first >

I want to erase some php code between a <? and a ?> in HTML containing a keyword, the problem is it finds the last > and wipes out everything before it how do i specify for it to stop searching after the first >? perl -i -p0e 's/<\?php.*keyword.*\?>//s' there's many lines of php code... (2 Replies)
Discussion started by: vanessafan99
2 Replies

4. Shell Programming and Scripting

finding users first name and last name

can someone help me how do i do this.. Display user id, first and last names of all the members of your CIS132 class in alphabetical order by last name. Hint: • All classmate names are in the file /etc/passwd • the first 5 characters in the user id are the same for all class members. (s132a) (1 Reply)
Discussion started by: an2up
1 Replies

5. Web Development

Intersection and union of array by hash

Hi, A piece of script from Perl-cookbook I do not understand, and post here for explanation. The purpose is to find the element in either array (union), and in both array (intersection). Thank you in advance. @a=qw(1 3 5 6 7 8); @b=qw(2 3 5 7 9); foreach $e (@a, @b) {$union{$e}++ &&... (3 Replies)
Discussion started by: yifangt
3 Replies

6. Shell Programming and Scripting

Find the intersection between two files

How can find the intersection between files for Example: file1 entry1 entry2 entry3 entry33 file2 entry2 entry4 entry5 . . . . the output should be entry2 (9 Replies)
Discussion started by: makrami
9 Replies

7. UNIX for Dummies Questions & Answers

finding out user name from an ip

if i know the ip of a computer on the subnet, it it possible to findout the username of the user that is using that system? (4 Replies)
Discussion started by: purest
4 Replies

8. Shell Programming and Scripting

help with finding a string

Hello folks I have a text file abcd.txt and has a line starting with number '8'. I have a string in this line starting at position 'a' to position 'b' also this string is a number and have to be reduced by 1. there is also a problem that it has to be padded with zeros to make the string... (2 Replies)
Discussion started by: sandyg
2 Replies

9. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies

10. UNIX for Dummies Questions & Answers

Finding how done IT

HellOooO, How I can find how delete a drictory in the system.If there's 2 root one of them outside the country but we have WAN so he can access the network from outside >>>> we are using same account so how I can know who done it I want to proof that. Regards (5 Replies)
Discussion started by: geoquest
5 Replies
Login or Register to Ask a Question