Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract tar archive from stdin?

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.

like image 670
Charlie Avatar asked Jul 17 '12 14:07

Charlie


People also ask

How do I extract tar file?

To extract (unzip) a tar. gz file simply right-click on the file you want to extract and select “Extract”. Windows users will need a tool named 7zip to extract tar.

How do I unzip a tarball file?

Simply right-click the item you want to compress, mouseover compress, and choose tar. gz. You can also right-click a tar. gz file, mouseover extract, and select an option to unpack the archive.


1 Answers

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 - 
like image 57
Thor Avatar answered Sep 18 '22 12:09

Thor