开发者

How to use 'patch' command with the standard output?

开发者 https://www.devze.com 2022-12-17 00:34 出处:网络
I\'m trying to catch an output of bash patch on stdout, but I receive an error: pa开发者_如何转开发tch -o- some/file

I'm trying to catch an output of bash patch on stdout, but I receive an error:

pa开发者_如何转开发tch -o- some/file 
patch: can't output patches to standard output

Can I get the patch result on stdout?


There are a couple of ways to do this.

  1. Use a temporary file to collect the patched file, cat the temp file and then delete it. A one-liner would be:

    patch fileToPatch patch.diff -o temp.out;cat temp.out;rm temp.out
    
  2. Send the output directly to /dev/tty:

    patch fileToPatch patch.diff -o /dev/tty
    


You can use "-o -" to explicitly redirect the output to stdout:

patch fileToPatch patch.diff -o -

Hope it helps

0

精彩评论

暂无评论...
验证码 换一张
取 消