Bash – Apply multiple .patch files

bashdiff()patch-managementxargs

I have a directory with .patch files, generated using diff.

I would like to apply all those patches using patch -p1 to another directory.

But patch takes only one file, unless I cat.

What would the command be to apply multiple files using xargs or a similar tool.

Best Answer

If cat works, why not use it?

To use find and xargs:

find dirname -name namespec -print0 | xargs -0 patch patchargs

Example:

find src/networking -type f -name 'network*.patch' -print0 | xargs -0 patch -p2
Related Topic