Find the intersection between two files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find the intersection between two files
# 8  
Old 04-30-2008
hope this one helps for you

awk '{ chk_str="grep ^"$0"$ ./file2_name" ; system(chk_str) }' file1_name
# 9  
Old 04-30-2008
Hi.

The command comm finds simple differences and the intersection between the contents of two sorted files. Here is the latter:
Code:
% comm -12 file1 file2

Producing:
Code:
entry2

See the man page for details ... cheers, drl
# 10  
Old 05-03-2008
Bug

Quote:
Originally Posted by makrami
its give me nothing
It is working fine for me.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find -ctime -1 cannot find files without extention

The problem is this one. I tar and gzip files on remote server find . -ctime -1 | tar -cvf transfer_dmz_start_daily.tar *${Today}*.*; Command find . -ctime -1 Doesn't find files without extension .csv .txt I have to collect all files for current day, when the program... (1 Reply)
Discussion started by: digioleg54
1 Replies

2. Shell Programming and Scripting

Find command to find a word from list of files

I need to find a word '% Retail by State' in the folder /usr/sas/reports/RetailSalesTaxallocation. When I tried like below, -bash-4.1$ cd /usr/sas/reports/RetailSalesTaxallocation -bash-4.1$ find ./ -name % Retail by State find: paths must precede expression: Retail Usage: find ... (10 Replies)
Discussion started by: Ram Kumar_BE
10 Replies

3. 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

4. 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

5. UNIX for Dummies Questions & Answers

find Search - Find files not matching a pattern

Hello all, this is my first and probably not my last question around here. I do hope you can help or at least point me in the right direction. My question is as follows, I need to find files and possible folders which are not owner = AAA group = BBB with a said location and all sub folders ... (7 Replies)
Discussion started by: kilobyter
7 Replies

6. Shell Programming and Scripting

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 tom ram 10 20 hey bye 11 12 bus cat 20 30 put but 25 30 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... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

7. 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

8. Shell Programming and Scripting

what is the find to command to find the files created last 30 days

what is the find to command to find the files created last 30 days (5 Replies)
Discussion started by: rajkumar_g
5 Replies

9. Shell Programming and Scripting

Little bit weired : Find files in UNIX w/o using find or where command

Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same. Thanks in advance. Regards Jatin Jain (10 Replies)
Discussion started by: jatin.jain
10 Replies

10. Shell Programming and Scripting

Find files older than 20 days & not use find

I need to find files that have the ending of .out and that are older than 20 days. However, I cannot use find as I do not want to search in the directories that are underneath the directory that I am searching in. How can this be done?? Find returns files that I do not want. (2 Replies)
Discussion started by: halo98
2 Replies
Login or Register to Ask a Question