Howdy, I have a diff file in my /var/tmp and would like to apply patch to a file in a different directory (other than /va/tmp). I tried using patch with -d switch, but that doesn't work. It complains abt 'patch: **** Can't open patch file tilda.diff : No such file or directory'. Do I need to copy my diff file to the directory where original file resides? Or is there any other way round? - CS.
Hi, On Thu, Sep 10, 2009 at 14:04, Carlos Santana <neubyr at gmail.com> wrote:> I have a diff file in my /var/tmp and would like to apply patch to a > file in a different directory (other than /va/tmp). I tried using > patch with -d switch, but that doesn't work. It complains abt ?'patch: > **** Can't open patch file tilda.diff : No such file or directory'. Do > I need to copy my diff file to the directory where original file > resides? Or is there any other way round?Try: cd /path/to/file/to/be/patched patch -p0 </var/tmp/tilda.diff You might want to use -p1 or -p2 or -p3... depending on what is the path to the file inside the .diff file. To figure that out, open the .diff file and look at the lines that start with --- and +++, then see how many directories are there before the filename, use that number for the argument to -p. HTH, Filipe
Frank.Brodbeck at klingel.de
2009-Sep-11 08:48 UTC
[CentOS] Antwort: patching from different directory
Hi Carlos Santana <neubyr at gmail.com> schrieb am 10.09.2009 20:04:02:> Howdy, > > I have a diff file in my /var/tmp and would like to apply patch to a > file in a different directory (other than /va/tmp). I tried using > patch with -d switch, but that doesn't work. It complains abt 'patch: > **** Can't open patch file tilda.diff : No such file or directory'. Do > I need to copy my diff file to the directory where original file > resides? Or is there any other way round?The exact command you executed would've been nice. -d should work and so it does for me (though this particular usecase is on an OpenBSD box). If you haven't already tried it do the following from anywhere on your system: patch -d /other/dir -i /var/tmp/tilda.diff -p0 I'm not sure if the order of the options matters, so you might have to consult patch(1). Please test the above patch command and report back as I'd say it is a bug if it doesn't work. If it didn't work please also post the full patch command and the output of head -5 /var/tmp/tilda.diff Frank.