0

I am trying to apply patches for multiple files. These files are present in different directories at different levels in a top-level directory. The directory structure is same for the patch files also.

Is there any way in which I can apply all patches at once?

I'm applying them individually using patch -p1 command.

1 Answers1

0

You could do something like:

find . -iname '*.patch' -execdir sh -c 'patch -p1 < $0' {} \;

This find command:

  • looks for files in the current directory (.) recursively
  • that are have filenames ending in .patch (adjust according to whatever naming pattern your patch files follow)
  • and in the directory where a matching file was found, runs sh -c 'patch -p1 < $0' matched-file:
    • $0 is the first argument, which is the matched file, so the command is essentially patch -p1 < matched-file
    • sh -c is needed since we're using redirection.
muru
  • 197,895
  • 55
  • 485
  • 740