Solved

How to use diff ?

Posted on 2002-05-13
6
290 Views
Last Modified: 2010-04-21
I would like to use diff to compare two files.
I don't care for the CASE(A and a are same).
I would I do it ?
0
Comment
Question by:tanc02
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 21

Expert Comment

by:tfewster
ID: 7006448
diff -i file1 file1 will show the lines where the files differ, ignoring case. (man diff)

You may prefer to use sdiff to show the 2 files side by side, with the differences marked
0
 
LVL 21

Expert Comment

by:tfewster
ID: 7006455
diff -i file 1 file2 (-i ignores case)

You may prefer to use sdiff to display the files side-by-side
0
 
LVL 21

Expert Comment

by:tfewster
ID: 7006459
Whoops, wasn't sure if the 1st post had worked :-)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:tanc02
ID: 7006469
This is waht I have in file 1 :
1
2
3
4
5

in file 2 :
1
2
5
6
7

Then, I issued this command : diff -1 1 2, and I got :

3, 4d2
< 3
< 4

5a4, 5
> 6
> 7

Can anyone show me how to read that output ?
0
 
LVL 21

Expert Comment

by:tfewster
ID: 7006560
diff only shows the differences between the 2 files. The "codes" are the ed commands needed to change file1 so it is identical to file2 - i.e. delete 2 lines from file1 and append two of the lines from file2.

The < and > shows the detail of the lines that are actually different between the two files.



0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 50 total points
ID: 7006882
> Can anyone show me how to read that output ?
read output as follows:

  remove from first file line 3 and 4 (3,4d2)
  then add in first file after previous line 5 line 4 and 5 (aka: line 6 and 7 from second file) (5a4,5)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question