When I right-click a file in Mac OSX and select "Compress 'File Name'", what is the equivalent bash or terminal command to get the same result?
Is it just
gzip -9 /path/to/filename?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
gzip is a different, incompatible algorithm. It's better compression, and not encumbered by any patents, but it's only supported out of the box on Unix and Unix-like systems (including Linux and OSX, but not Windows). What you're looking for is
zip. OSX ships with that as a command-line utility too. See
man zip for options.
If you 'Compress' a directory/folder called
myDir, or something like that, then you get the equivalent of
% zip -r myDir.zip myDir
If you 'Compress' a single file,
f1, then you get something like
% zip -r f1.zip f1
You can unpack Zip archives with
unzip, and list their contents with
Just by the way, one important difference between Zip and gzip is that Zip is both an archiver and a compressor, whereas gzip is designed only to compress single files. The files that gzip compresses might be archive files (most commonly tar files), but the two jobs are separate. If you want really good compression, then
bzip2 (see the man page) is reported to be more effective even than