LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-29-2011, 09:57 AM   #1
sasanthi
LQ Newbie
 
Registered: Jul 2011
Posts: 11

Rep: Reputation: Disabled
generate a matrix of similarities between multiple files


Hi all,

I have four files

file1
one
two
three
four

file2
one
two
five

file3
three
four
five

file4
four
five
one
two

And I want to compare them and create a matrix with number of common lines between them, such as:
file1 file2 file3 file4
file1 0 2 2 3
file2 2 0 1 3
file3 2 1 0 2
file4 3 3 2 0

Could someone help me of writing a perl script? Can I do that quickly with awk? I tried to create arrays of arrays, but it doesn't work.

I would appreciate if you can help me.

thanks
 
Old 08-29-2011, 06:06 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,356

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
Pick a language and start writing code. Do it in small steps i.e. don't try to do the whole thing straight away.
If you get stuck, come back and show us your code; we'll help but we won't do it for you.
If you choose Perl (a fine lang), here are some very good links:
http://perldoc.perl.org/
http://www.perlmonks.org/?node=Tutorials

Good Luck
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Parallel matrix - matrix multiplication seg-faults ejspeiro Programming 9 04-18-2011 09:41 PM
Comparing two linux files for diffirences and similarities. secondchanti Linux - Newbie 5 07-27-2010 12:37 AM
how to generate multiple ssl certificate yogesh619 Linux - General 1 04-30-2009 08:36 AM
awk convert column matrix to square matrix? johnpaulodonnell Programming 4 04-30-2008 01:45 PM


All times are GMT -5. The time now is 10:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration