LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 02-12-2015, 01:09 PM   #1
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 258

Rep: Reputation: Disabled
tar -zxvpf echolot-2.1.9.tar.gz


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.

Thanks.
 
Old 02-12-2015, 02:01 PM   #2
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Perhaps it's not possible.
Well you can use mv to move contents of base directory into current directory. And use rmdir base directory.
 
Old 02-12-2015, 02:16 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by battles View Post
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 View Post
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.
 
Old 02-12-2015, 02:21 PM   #4
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 258

Original Poster
Rep: Reputation: Disabled
Thanks. I have read some more on it and found some of that. I did just end up doing a move.
 
Old 02-12-2015, 10:52 PM   #5
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
Originally Posted by TB0ne View Post
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.
 
Old 02-13-2015, 07:42 AM   #6
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 258

Original Poster
Rep: Reputation: Disabled
Thanks. man pages are sometimes a pain to find the correct answers.
 
Old 02-13-2015, 08:35 AM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by veerain View Post
I have tar version 1.27.1 from ftp.gnu.org/gnu/tar. It doesn't supports this option --one-top-level.
Version 1.28 does....since you're using LFS, it's odd you don't have the latest versions of things compiled/installed.
Quote:
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.
...and yet you said "Perhaps it's not possible."? Please, before misleading people with an incorrect answer, do some basic research first.
 
Old 02-13-2015, 08:47 AM   #8
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 258

Original Poster
Rep: Reputation: Disabled
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.

Linux 3.2.0-4-686-pae i686
Distributor ID: Debian
Description: Debian GNU/Linux 7.5 (wheezy)
 
Old 02-13-2015, 10:41 PM   #9
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
Originally Posted by TB0ne View Post
Version 1.28 does....since you're using LFS, it's odd you don't have the latest versions of things compiled/installed.

...and yet you said "Perhaps it's not possible."? Please, before misleading people with an incorrect answer, do some basic research first.
I did my basic research. But it is not necessary it would be fruitful.
 
Old 02-14-2015, 09:48 AM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by veerain View Post
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.
 
Old 02-14-2015, 04:18 PM   #11
yx0p
LQ Newbie
 
Registered: Feb 2015
Posts: 14

Rep: Reputation: Disabled
Yeah it is possible.

In addition - if you have a load of files and folders within a folder called "mytarfolder"

cd mytarfolder
tar -pczf mytarfolder.tar.gz *

That way when you extract the tar folder all of the files and folders within the tar.gz file will extract to the folder where the tar.gz file is.

Good Luck!
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
"Invalid tar magic" error msg. when I try to tar ldmud *.tar file in DSL pixxi451 Linux - Newbie 4 07-04-2010 08:32 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration