P
P
pdx2011-01-24 11:39:50
Command line
pdx, 2011-01-24 11:39:50

Extract folder from tar archive to another tar archive?

There is a tar.gz archive created by the command tar -cpzf ... , that is, compressed with gzip and with preservation of rights. Let's say it has the following folder structure:
earth
moon
sun

Is it possible to create an archive with the same parameters, only containing only one of the folders, with one command? For example, so that the structure contains only one folder:
moon
One command. That is, without resorting to manual unpacking, and then packing the necessary folders.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
intr, 2011-01-24
@pdx

tar -cpzf new.tar.gz --include="moon" @old.tar.gz

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question