How to apply a patch as part of a pipe? In other words, how to patch stdin?
2
votes
2
answers
1202
views
I want to apply a unified diff from
mypatch.diff
to stdin and output the result to stdout.
So far, I have tried:
patch -i mypatch.diff -o - -u originalfile
Which successfully applies mypatch.diff
and prints the result to stdout. However, I still have to provide the original file as originalfile
, not via stdin.
And if I try something like:
patch -i mypatch.diff -o - -u -
Then the patch gets rejected:
patching file -
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file -.rej
Asked by finefoot
(3554 rep)
Feb 27, 2023, 04:32 PM
Last activity: Mar 3, 2023, 11:26 PM
Last activity: Mar 3, 2023, 11:26 PM