Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I generated patch using diff command with the number of context lines as 1 (-c option). My patch file contents:

*** /home/sk/abc/def/src/klm/a.py 2015-05-18 16:25:50.348398554 +0530
--- /opt/abc/def/ghi/klm/a.py  2015-05-18 14:27:13.860503469 +0530
***************
*** 72,73 ****
--- 72,74 ----
              output, error, rCommand = "", "", ""
+             import subprocess
              rCommand = self.copyCmd % (self.executor_hostname, self.testId, self.testId)

When i did cd to the root directory, / and tried to apply the patch using patch -p0 < sg.patch command, I get this prompt,

 can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|*** /home/sk/abc/def/src/klm/a.py  2015-05-18 16:25:50.348398554 +0530
|--- /opt/abc/def/ghi/klm/a.py  2015-05-18 17:10:48.368670076 +0530
--------------------------
File to patch:

Why doesn't the patch command take the file name in second line as the file to patch?

share|improve this question
    
Duplicate of unix.stackexchange.com/questions/167216/… . –  javabrett May 18 at 11:53
    
hi javabrett, thanks for your info.. i have changed the question and its error message... –  Madhavan Kumar May 18 at 12:53

1 Answer 1

You need to be in the root directory to apply the patch with an absolute path, and apply the -p0 option. See also this post.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.