How to untar an archive without the root folder, but keeping the full hierarchy inside it?
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Music Box Puzzles
--
Chapters
00:00 Question
00:42 Accepted answer (Score 105)
01:29 Thank you
--
Full question
https://superuser.com/questions/899684/h...
Accepted answer links:
[tar]: http://linux.die.net/man/1/tar
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#commandline #tar
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Music Box Puzzles
--
Chapters
00:00 Question
00:42 Accepted answer (Score 105)
01:29 Thank you
--
Full question
https://superuser.com/questions/899684/h...
Accepted answer links:
[tar]: http://linux.die.net/man/1/tar
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#commandline #tar
#avk47
ACCEPTED ANSWER
Score 133
Easy. Just use --strip-components=1
on the archive like this:
tar -xf archive.tar --strip-components=1
And as explained in the official tar
man page:
--strip-components=NUMBER
strip NUMBER leading components from file names on extraction
With the logic being that if a path consists of foo/something.txt
then the first “component” of that path would be foo/
so --strip-components=1
would effectively drop the foo/
from the path foo/something.txt
.