Skip to content

Instantly share code, notes, and snippets.

Last active November 23, 2023 19:02
  • Star 59 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Merge and extract tgz files from Google Takeout

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
Copy link

paradite commented Jul 5, 2023

Just a note for those who exported zip on macOS. You can merge the zip files simply with:

unzip \*.zip [Return]

(backslash is to escape * which would be expanded by default)


Copy link

johannesunana commented Jul 17, 2023

Thank you @chabala and @bvc3at! This worked for me on Windows 10 using Ubuntu on WSL. Glad I saw this as the top result.

Copy link

chabala commented Oct 25, 2023

gist comments are not a Q&A forum. If you have unix questions, ask them on StackOverflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment