Modifying the path inside an archive for extraction

0

I would like to change the path of extraction of a .tar.gz archive. The files are supposed to extract as ./1/2/3/4/files, ./1/2/3files and so on.

The .1/2 part of those is common to all the files.

My question is, how can I modify the extraction path to extract into ./2/ and completely ignore the 1 directory?

Aarohi Johal

Posted 2012-02-13T20:19:14.280

Reputation: 415

2I assume Linux, but tagging the OS would probably be a good idea too. – EBGreen – 2012-02-13T20:20:57.427

Answers

1

Generally you use the --strip-components=n option for this using gnu tar. It strips n leading directories from the paths.

Zoredache

Posted 2012-02-13T20:19:14.280

Reputation: 18 453