cd /news/developer-tools/merge-and-extract-tgz-files-from-goo… · home topics developer-tools article
[ARTICLE · art-9892] src=gist.github.com ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

Merge and extract tgz files from Google Takeout

The article explains that Google Takeout splits large data exports into multiple numbered `.tgz` files, and the most efficient way to extract them is by concatenating the files using `cat` with brace expansion or globbing, then piping the combined stream directly into `tar` for extraction. This method avoids the need for custom scripts or manual merging of partial directories, as `tar` handles multipart archives natively. Additionally, users can monitor extraction progress by piping the output through the `pv` command.

read1 min views20 publishedOct 27, 2020

Recently found some clowny gist was the top result for 'google takeout multiple tgz', where it was using two bash scripts to extract all the tgz files and then merge them together. Don't do that. Use brace expansion, cat the TGZs, and extract:

$ cat takeout-20201023T123551Z-{001..011}.tgz | tar xzivf -

You don't even need to use brace expansion. Globbing will order the files numerically:

$ cat takeout-20201023T123551Z-*.tgz | tar xzivf -

tar has been around forever, they didn't design it to need custom scripts to deal with multipart archives. Since it's extracting the combined archive, there's no 'mess of partial directories' to be merged. It just works, as intended.

An additional tip, courtesy of Dmitriy Otstavnov (@bvc3at): if you have pv available, you can track the progress of the extraction:

> pv takeout-* | tar xzif -
 190GiB 2:37:54 [18.9MiB/s] [==============>                                   ] 30% ETA 5:03:49
── more in #developer-tools 4 stories · sorted by recency
── more on @google takeout 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/merge-and-extract-tg…] indexed:0 read:1min 2020-10-27 ·