Guide
How to open and edit a .gz file on a Mac
A compressed text file is a text file with a wrapper on it. A rotated log, a database dump, a configuration file out of a backup — each one is text you want to read, and an editor that answers “binary” to it is an editor that sends you to the command line to do the thing it exists for.
The usual way, and what it costs
gunzip -c access.log.gz | less reads it. zgrep ERROR
access.log.gz searches it. gunzip access.log.gz, edit,
gzip access.log writes it back — and along the way you have a second copy
of the file on a disk that may not have room for it, a moment where only the unpacked
copy exists, and a compression setting on the way back in that may not match the one it
came with.
Double-clicking it in the Finder is worse: Archive Utility unpacks it beside the
original and leaves both, which is how a folder ends up with dump.sql and
dump.sql.gz that disagree.
Opening one as text
In Volt a .gz opens as its text and saves as a .gz again.
.bz2, .zst and .xz do the same, with nothing to
install for any of them.
What is inside decides everything. nginx.conf.gz is highlighted as
an nginx configuration and dump.sql.bz2 as SQL, each with the icon it
would have without the wrapper. The character-set detector, the line index, Find and
undo all work on the text, so nothing behaves differently because the file arrived
packed.
The bytes decide, not the name. A file in gzip’s format is unpacked whatever
it is called — which matters for the nameless dump and for access.log.1.gz
alike. Save under a name that ends in .gz and it is packed again; save
under one that does not and the text is written out plain, which is the only way to get
a file out of its wrapper from inside an editor.
As hard as it came. A file packed at the strongest setting is packed that way again, so a backup does not quietly grow because it was opened.
Several members are one text. Appended logs, cat a.gz b.gz >
both.gz, anything bgzip writes: a gzip file made of several compressed parts is
one document rather than a refusal or a first chunk.
The space bar in the Finder
Press the space bar on a .gz and Quick Look shows the text inside it —
the first part of it, as a preview should — instead of telling you it is an archive. A
.tar.gz still says it is an archive, because several files with a table of
contents is not a text file.
The one thing it costs
A compressed file has to be unpacked to be read, so it is the one case where the size
of the file costs memory. An uncompressed 4 GB log opens in two milliseconds on a few
megabytes; a 4 GB .gz is a different proposition, and Volt says so in the
status bar rather than pretending otherwise. For everyday compressed files — logs,
dumps, configs, exports — this never comes up.
What this is for
- Reading last week’s rotated log without filling the disk with this week’s copy.
- Fixing one line in a configuration file inside a backup and putting it straight back.
- Searching a compressed dump with real find and replace, markers and filters rather
than with
zgrepone question at a time. - Checking what an export actually contains — which character set, which line endings — before handing it to something that will guess.
Questions
Which compressed formats can Volt open?
gzip (.gz), bzip2 (.bz2), Zstandard (.zst) and xz (.xz), all of them as text, and all of them saved back the same way.
Does it unpack the file to disk first?
No. There is no second copy beside the original and nothing to tidy up afterwards.
Will saving change the compression?
No. A file packed at the strongest setting is packed that way again. Saving under a name without the extension writes the text out plain, which is how you unwrap one deliberately.
What about a .tar.gz?
That is an archive of several files rather than one text, so Volt does not pretend it is a document. Unpack it first.
Can it open a .gz made of several parts?
Yes. Appended logs and anything bgzip writes read as one text.
Is a compressed file as fast as an ordinary one?
Opening a very large compressed file costs memory in a way an ordinary one does not, because it has to be unpacked to be read. For the sizes compressed logs and dumps usually come in, it is immediate.
Open a .gz and see the text
Volt is in free beta. Download it now — no account, no sign-up — and try it on the file you have in mind. Each build runs for seven days, and every update gives another seven.
macOS 13 or later, Apple silicon. About 7 MB, signed and notarised. Everything it does · what changed in this build.
Related
- Reading a log file on a Mac — rotated logs, filters and jumping to a time.
- Opening a large CSV on a Mac — compressed exports included.
- Every file Volt opens — the complete list.
- Opening large files on a Mac — the measured figures.