How to extract tar archive from stdin?

孤人 提交于 2019-12-03 06:30:18

问题


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.


回答1:


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 -


来源:https://stackoverflow.com/questions/11524602/how-to-extract-tar-archive-from-stdin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!