[CentOS] patching from different directory

Thu Sep 10 18:12:15 UTC 2009
Filipe Brandenburger <filbranden at gmail.com>

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