So I'm pretty new to Ubuntu and the whole Linux environment though I'm a computer scientist and I want to become familiar with the basic commands.
At the moment I am working with .tar and .tar.gz files and I have a problem creating one of them.
Let's assume I have the following file structure:
./
|-> a
|-> Release
|-> [some files]
|-> b
|-> Release
|-> [some files]
With the following commands I currently create my tar-file:
tar -cvf ../archive.tar a
tar -rvf ../archive.tar b
Now my archive.tar also has the format
archive.tar
|-> a
|-> Release
|-> [some files]
|-> b
|-> Release
|-> [some files]
Now let's come to my question:
How can I achieve the following three archive structures given the said file structure above:
-
Add a common base folder
archive.tar |-> baseFolder |-> a |-> Release |-> [some files] |-> b |-> Release |-> [some files]
-
Rename the folders
archive.tar |-> aChangedFolderName |-> Release |-> [some files] |-> bChangedFolderName |-> Release |-> [some files]
-
Add a common base folder and rename the folders
archive.tar |-> baseFolder |-> aChangedFolderName |-> Release |-> [some files] |-> bChangedFolderName |-> Release |-> [some files]
For me it doesn't matter if it just can be accomplished in multiple steps, at least I hope I can do it.
And: #1 would be the most important to me.
Best Answer
You can do 1. with the following command:
The archive will contain:
For 2. you can run
tar
with multiple--transform
options:The archive will contain:
For 3. you can combine 1. and 2. as follows:
The archive will contain: