LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-23-2009, 04:16 AM   #1
zoubidoo
LQ Newbie
 
Registered: Mar 2004
Posts: 27

Rep: Reputation: 15
How to sort two files then diff them?


I'd like to sort two files then do a diff. It's easy to:
Code:
$ sort file1 > file1_sorted
$ sort file2 > file2_sorted
$ diff file1_sorted file2_sorted
but can it be done without storing the intermediate files?

The best I have managed is storing only one file:
Code:
$ sort file2 > file2_sorted
$ sort file1 | diff - file2_sorted
Is it possible to store no intermediates?

Cheers,
Zoubidoo
 
Old 01-23-2009, 04:30 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
In bash you can try process substitution:
Code:
diff <(sort file1) <(sort file2)
 
Old 01-23-2009, 04:42 AM   #3
zoubidoo
LQ Newbie
 
Registered: Mar 2004
Posts: 27

Original Poster
Rep: Reputation: 15
Perfect! Thank you colucix.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Diff bet two files amitpardesi Programming 6 08-10-2007 07:26 AM
is it possible to diff ps files? markhod Linux - General 8 09-05-2005 12:17 AM
Diff compare 2 files DavidTempler Linux - Newbie 2 11-01-2004 10:00 AM
diff for binary files? thorax Linux - Software 2 07-17-2004 02:15 PM
.diff files? jtsai256 Linux - Newbie 1 09-28-2003 02:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:46 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
Open Source Consulting | Domain Registration