Solved

How to use diff ?

Posted on 2002-05-13
6
275 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
  • 4
6 Comments
 
LVL 20

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 20

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 20

Expert Comment

by:tfewster
ID: 7006459
Whoops, wasn't sure if the 1st post had worked :-)
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 20

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now