LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-27-2014, 05:04 AM   #1
literaturedevourer
LQ Newbie
 
Registered: Oct 2014
Posts: 2

Rep: Reputation: Disabled
Comparing two unsorted files using comm.


Hi all,
I want to compare two unsorted files, file1 and file2 by using comm command in one line.

So far I have tried -
sort file1|comm `sort file2`

or such similar pipe options and have failed. Please help.
 
Old 10-27-2014, 05:10 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
There is a bash-specific method:
Code:
comm <(sort file1) <(sort file2)
 
2 members found this post helpful.
Old 10-27-2014, 05:21 AM   #3
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Have you looked at named pipes?

Code:
mknod A p
mknod B p
sort filea > A &
sort fileb > B &
comm A B
 
1 members found this post helpful.
  


Reply



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] uniq values in unsorted file upendra_35 Linux - Newbie 15 08-03-2013 01:21 AM
Comparing two files. ted_chou12 Linux - Software 1 09-29-2012 05:22 AM
Comparing 2 files ravi_nandula Linux - Newbie 7 07-09-2012 12:39 PM
[SOLVED] Comparing two files p3rcy Programming 10 02-14-2012 12:27 PM
comparing files newbiesforever Linux - Software 3 07-07-2010 03:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:17 PM.

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
Open Source Consulting | Domain Registration