FG

Compressing a file in place - does "gzip -c file | dd of=file" really work?

Fresh3 days ago
Mar 15, 20263400 views
Confidence Score0%
0%

Problem

In the question How can I compress a file on Linux in-place, without using additional disk space?, one answer proposes to simply use I tried it (on Debian Linux), and it does appear to work. I don't quite understand why, however. Doesn't truncate its output file before writing? Wouldn't this "pull …

Error Output

gzip -c file | dd of=file

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Compressing a file in place - does "gzip -c file | dd of=file" really work?

Low Risk

Experiment shows that this does not work. I created a 2-megabyte file from , then tried the above command on it. Here are the results: Obviously a 2-megabyte random file won't compress to 25 bytes, and in fact running on the compressed file yields a…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment