1

is there any way to patch a file, that is compressed via gzip without decompressing it first? I tried

patch -n <(gzip -d file.gz) patch_to_file.diff > new_file

but I only got

patch: **** Can't create temporary file /dev/fd/63.o65LeZA : No such file or directory

as a result.

I'd like to avoid the storage overhead, so if there is any way to do this with pipes/process substitution I'd be very happy. :)

2
  • If the patch that you have is for the uncompressed data, then you must uncompress the data to patch it. Since patching a file changes it, you would additionally have to re-compress the data after patching. This is assuming that you don't have a binary patch for the compressed file itself (in which case you would not be able to use patch, which is for text files). Commented Jan 12, 2023 at 15:50
  • @Kusalananda Not disagreeing, but there are tools like zless which allow transparently exposing the plain text contents of a file without manually requiring a decompression step first. In a parallel universe, a tool like zpatch could exist which would answer the question. (Unfortunately?) we don't live in that universe, though :) Commented Jan 13, 2023 at 1:29

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.