Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

You must log in to answer this question.

Browse other questions tagged .