0

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?

KansaiRobot
  • 417
  • 7
  • 18
  • "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. – pLumo Jul 12 '23 at 07:42
  • Thanks but actually no. I found that I have to use `--strip-components 1` to do what I intend. Sorry for the confusion – KansaiRobot Jul 12 '23 at 07:44
  • That's the second answer in the linked post: https://askubuntu.com/a/470266/158442 – muru Jul 12 '23 at 07:55
  • @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. – pLumo Jul 12 '23 at 08:03

0 Answers0