Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I can't seem to find an example of how to unzip/tar files into the same directory as the zipped file.
tar -zxvpf thefile.tar.gz
It places it into a directory names thefile.
It will only create a "thefile" directory if your files were in that directory when the archive was created. Read the man page on the tar command...there are several options to look at, but the most promising is:
Code:
--one-top-level[=DIR]
Extract all files into DIR, or, if used without argument, into a subdirectory named by the base name of the archive (minus standard compres-
sion suffixes recognizable by --auto-compress).
---------- Post added 02-12-15 at 02:16 PM ----------
Quote:
Originally Posted by veerain
Perhaps it's not possible. Well you can use mv to move contents of base directory into current directory. And use rmdir base directory.
Wrong..it IS possible to do, if you had read the man page. Please don't post misleading or incorrect information.
It will only create a "thefile" directory if your files were in that directory when the archive was created. Read the man page on the tar command...there are several options to look at, but the most promising is:
Code:
--one-top-level[=DIR]
Extract all files into DIR, or, if used without argument, into a subdirectory named by the base name of the archive (minus standard compres-
sion suffixes recognizable by --auto-compress).
---------- Post added 02-12-15 at 02:16 PM ----------
Wrong..it IS possible to do, if you had read the man page. Please don't post misleading or incorrect information.
I have tar version 1.27.1 from ftp.gnu.org/gnu/tar. It doesn't supports this option --one-top-level.
But hey I found out another option which would work:
--strip-components=1
I somehow didn't remembered it. So tar does support what OP asked for.
root@me~# tar --version
tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
root@me~# apt-get install --only-upgrade tar
Reading package lists... Done
Building dependency tree
Reading state information... Done
tar is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 70 not upgraded.
I did my basic research. But it is not necessary it would be fruitful.
You did?? Then why did you say it may not have been possible, THEN come back and say it WAS??? If you DID your research, you would have seen it WAS possible from the start, and not posted something incorrect and misleading.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.