Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Node:patch Directories, Next:, Previous:Multiple Patches, Up:Merging with patch

Applying Patches in Other Directories

The -d directory or --directory=directory option to patch makes directory directory the current directory for interpreting both file names in the patch file, and file names given as arguments to other options (such as -B and -o). For example, while in a mail reading program, you can patch a file in the /usr/src/emacs directory directly from a message containing the patch like this:

| patch -d /usr/src/emacs

Sometimes the file names given in a patch contain leading directories, but you keep your files in a directory different from the one given in the patch. In those cases, you can use the -pnumber or --strip=number option to set the file name strip count to number. The strip count tells patch how many slashes, along with the directory names between them, to strip from the front of file names. A sequence of one or more adjacent slashes is counted as a single slash. By default, patch strips off all leading directories, leaving just the base file names.

For example, suppose the file name in the patch file is /gnu/src/emacs/etc/NEWS. Using -p0 gives the entire file name unmodified, -p1 gives gnu/src/emacs/etc/NEWS (no leading slash), -p4 gives etc/NEWS, and not specifying -p at all gives NEWS.

patch looks for each file (after any slashes have been stripped) in the current directory, or if you used the -d directory option, in that directory.


 
 
  Published under the terms of the GNU General Public License Design by Interspire