How to extract tar archive from stdin?

PipeStdinTarPipeline

Pipe Problem Overview


I have a large tar file I split. Is it possible to cat and untar the file using pipeline.

Something like:

cat largefile.tgz.aa largefile.tgz.ab | tar -xz

instead of:

cat largefile.tgz.aa largfile.tgz.ab > largefile.tgz
tar -xzf largefile.tgz

I have been looking around and I can't find the answer. I wanted to see if it was possible.

Pipe Solutions


Solution 1 - Pipe

Use - as the input file:

cat largefile.tgz.aa largefile.tgz.ab | tar zxf -

Make sure you cat them in the same order they were split.

If you're using zsh you can use the multios feature and avoid invoking cat:

< largefile.tgz.aa < largefile.tgz.ab tar zxf -

Or if they are in alphabetical order:

<largefile.tgz.* | tar zxf -

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCharlieView Question on Stackoverflow
Solution 1 - PipeThorView Answer on Stackoverflow