Score:0

How to extract the contents of a tar file into an existing directory

cn flag

Please do not mistake this question with "how to untar a tar file into an existing directory". For this question there are already answers such as this one

What I am trying to do is to untar an tar.gz file but put the contents into a directory

The linked answer for example when you do it creates a folder (with the name of the tar file) and puts the contents inside the folder

What I want is to not create the folder but put the contents inside an already existing directory.

How can this be done?

pLumo avatar
in flag
"What I am trying to do is to untar an tar.gz file but put the contents into a directory" - This is exactly what `tar -xf archive.tar -C /path/to/dir` is doing. There won't be any directories created with the name of the tar file.
cn flag
Thanks but actually no. I found that I have to use `--strip-components 1` to do what I intend. Sorry for the confusion
muru avatar
us flag
That's the second answer in the linked post: https://askubuntu.com/a/470266/158442
pLumo avatar
in flag
@KansaiRobot This is not true. `--strip-components` will remove the first direrectory INSIDE the `tar` file. So it is content of your `tar` file! `tar -x` won't create any other directories. Note: `--strip-components` means, that if you have the same file name in different directories, they might get overwritten.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.