How do I extract files from one tarball to another tarball in one step?
Posted
by
Martin
on Super User
See other posts from Super User
or by Martin
Published on 2014-06-06T15:14:27Z
Indexed on
2014/06/06
15:30 UTC
Read the original article
Hit count: 366
command-line
|tar
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.
© Super User or respective owner