LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 04-10-2007, 01:53 PM   #1
rajbal
LQ Newbie
 
Registered: Apr 2007
Posts: 2

Rep: Reputation: 0
How to avoid some differences in Diff command


Hi ,
I am trying to make the diff skip some of the differences which i know might appear.Is there a way to avoid displaying the selected difference in two file.I know there is a option "--ignore-matching-lines=" in the diff but that is useful to get rid of lines that are added or deleted.I want to avoid lines which are real difference.

Regards,
RAJESH
 
Old 04-10-2007, 05:38 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
The --ignore-matching-lines= option checks changed lines as well as those added or deleted. However, the original and changed lines have to match the regular expression. From the man page:
Code:
       -I RE  --ignore-matching-lines=RE
              Ignore changes whose lines all match RE.
What this means is if you have the following file1:
Code:
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
And the following file2:
Code:
line 1
line added
line 2
line 3
line 4
line 6
line 7
line 8 changed
line 9
You get the following outputs:
Code:
$ diff file1 file2
1a2
> line added
5d5
< line 5
8c8
< line 8
---
> line 8 changed
$ diff --ignore-matching-lines='8.*' file1 file2
1a2
> line added
5d5
< line 5
$ diff --ignore-matching-lines='changed' file1 file2
1a2
> line added
5d5
< line 5
8c8
< line 8
---
> line 8 changed
It means that you have to construct your regular expression to catch both forms of the changed line (before and after)
 
Old 04-10-2007, 05:59 PM   #3
rajbal
LQ Newbie
 
Registered: Apr 2007
Posts: 2

Original Poster
Rep: Reputation: 0
Hi Gilead,
Can you explain what you mean by before and after here?

Regards,
Raj
 
Old 04-10-2007, 11:28 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
I was assuming that the files you were diff'ing were changed versions of one file. For example, the original file (the before file) had some changes made and was saved as the new file (the after file).

Or, in the case of individual lines in the file, the before line is the line the way it was in the original file. The after line is the line the way it is in the changed file.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use 'diff' command ursusman Linux - Newbie 1 03-08-2007 04:29 AM
Can diff display the differences/uniques for just one of the 2 files? gruffy Linux - Newbie 4 09-10-2006 02:17 PM
How does "diff" only show differences? daYz Linux - Software 11 01-05-2006 10:24 PM
help on diff command anandss2004 Programming 2 11-01-2005 12:58 PM
How avoid boot disk and 'startx' command? whitehof Linux - General 5 10-17-2002 02:21 PM


All times are GMT -5. The time now is 12:26 PM.

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