compress 1.pdf does not compress the file to 1.pdf.Z. But compress 1.sh compress the file to 1.sh.Z. (compress is /usr/bin/compress on macOS.) Does anybody know why is it so? How to make it compresses files regardless of file types?

1 Answer 1


From the man page:

If compression would not reduce the size of a file, the file is ignored.

Compress is using a very simple compression algorithm and for some files (like PDFs which are already using a compression), the algorithm is not able to reduce the file size. In this case, the result would actually be bigger. In this case, compress is simply leaving the file as-is.

Pass the -f flag if you do want to "compress" the file even if it would become bigger. From the man page:

-f Files are overwritten without prompting for confirmation. Also, for compress, files are compressed even if they are not actually reduced in size.

Since compress's algorithm isn't very good, I would recommend using a better compressor like bzip2 or xz if you're able to.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .