Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have some fairly large tarball archives, from which I need to extract some files. I will later repack those files to transfer them to another server. Currently that is a two (multi) step process for me:

mkdir ttmp
tar -vxzf large.tgz -C ttmp/ --strip-components=<INT> <folder-to-be-extracted>

or alternatively with wildcards

mkdir ttmp
tar -vxzf large.tgz -C ttmp/ --strip-components=<INT> \
    --wildcards --no-anchored '*pattern*'

Then I go ahead and recompress the created folder

tar -vczf small.tgz ttmp/*
rm -rf ttmp

How can I combine these two commands into one? Like this

tar -x large.tgz > tar -c small.tgz 

Just to show, what I already tried:

Whenever I search the terms "extract" I will end up here or here or even here. When I use the term "split" I will end up here and that is definitely not what I intend to do. When I use "repack" I end up in strange places.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.