Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

bash

patch

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

patch -o- some/file 
patch: can't output patches to standard output

Can I get the patch result on stdout?

like image 911
Enchantner Avatar asked Oct 23 '25 16:10

Enchantner


1 Answers

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
    
like image 59
Salo Avatar answered Oct 25 '25 06:10

Salo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!