As said the subject, we want to extract only the contents of a tar file to a specific folder.
I have my tar : myTarFolder.tar, my destination folder : destFolder
The structure of my tar file :
If we use only the tar command, we will get :
tar -xf myTarFolder.tar -C destFolder
If we want to get something like this :
The option that we have to use is :
- –strip-components=NUMBER : strip NUMBER leading components from file names on extraction
An example of the command :
tar -xf myTarFolder.tar --strip-components=1 -C destFolder
The result :