Jump to content

How to use diff correctly?


Guest daYz
 Share

Recommended Posts

Hi,

 

Can someone tell me how I should use the diff utility? I want to patch traceroute with a traceroute diff patch. The first two lines of the traceroute-diff file are --- traceroute.c.orig and +++ traceroute.c so I have presumed that I should patch the traceroute.c file that was in the traceroute tarball.

 

The problem is that when I try to patch traceroute, the two files are both fully added into another file instead of making an updated file.

 

I have used the command:

diff traceroute-diff traceroute.c > traceroute.c

 

The other files included in the tarball are:

 

CHANGES

FILES

INSTALL

Makefile.in

README

VERSION

aclocal.m4

config.guess

config.sub

configure

configure.in

findsaddr-generic.c

findsaddr-linux.c

findsaddr-mib.c

findsaddr-socket.c

findsaddr.h

ifaddrlist.c

ifaddrlist.h

install-sh

lbl/gnuc.h

lbl/os-solaris2.h

lbl/os-sunos4.h

linux-include/netinet/in_systm.h

linux-include/netinet/ip.h

linux-include/netinet/ip_icmp.h

linux-include/netinet/ip_var.h

linux-include/netinet/udp.h

linux-include/netinet/udp_var.h

mean.awk

median.awk

mkdep

rip_output.c

strerror.c

traceroute.8

traceroute.c

traceroute.h

usleep.c

 

Thanks for your help

Link to comment
Share on other sites

i havent done diff and patch before but from how i understood it you create first a diff, and then patch it afterwards. something like this

 

diff file1 file2 > patch.0

patch file2 <patch.0

 

but you better do some more googling and reading as i wont bet my life (and my system) on what i have just said. :#:

 

ciao!

Link to comment
Share on other sites

make a copy of the file you want to "fix".

 

edit it and rename it file.c.orig place it in the same directory as the original. then:

 

diff -ruN /path/to/original/file.c /path/to/newfile.c.orig > patchname.patch

 

then apply the patch as mentioned above.

 

if you are only making a very small change to the file you may want to consider using sed instead.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...