LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 05-23-2004, 12:40 PM   #1
xianzai
Member
 
Registered: Oct 2003
Location: UK
Distribution: RHEL4
Posts: 54

Rep: Reputation: 15
Question Comparing 2 Files


Hi there,

I need to compare 2 files (in the terminal), and output lines that are the same in both. I have found a lot of tools that can tell me the different lines, any idea how to display the lines common to both please?

Thanks!

M
 
Old 05-23-2004, 12:46 PM   #2
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Code:
diff -u file1 file2 | grep -v '^[+-]'
 
Old 05-23-2004, 12:50 PM   #3
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Oh well.. you get more similar lines by giving -UaLargeNumber instead of -u, eg. -U3000, because the -u gives only 3 lines of context around changes.
 
  


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
Comparing 2 Files for Duplicates Mr_H Linux - Newbie 5 11-09-2005 01:43 PM
comparing lots of files Frustin Linux - General 4 09-22-2005 03:54 PM
Using diff for comparing 2 files beep Programming 5 01-21-2005 01:51 PM
Comparing files contents? hhegab Linux - Newbie 3 07-01-2004 01:45 AM
Comparing files on creation time StarTux Programming 2 08-29-2003 02:08 PM


All times are GMT -5. The time now is 03:33 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration