LinuxQuestions.org
Visit Jeremy's Blog.
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 12-09-2008, 02:39 AM   #1
mitesh.ever
LQ Newbie
 
Registered: May 2006
Posts: 22

Rep: Reputation: 15
Lightbulb extracting .tar.gz files in current directory...


Please let me know how to extracting .tar.gz files in current directory...without creating new directory, that it will create..automatically..

thanks!!
 
Old 12-09-2008, 02:53 AM   #2
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 61
The package is a tarred directory, it will be unpacked as is.
 
Old 12-09-2008, 04:45 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
GNU tar has a lot of options. One of this is --strip-components which strips a given number of leading components from file names before extraction. For example
Code:
tar --strip-components=1 -zxf file.tar.gz
will strip out the first directory from the path of the archived files.
 
Old 12-09-2008, 05:31 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
You could force it to extract to the current directory (in spite of this being the default behaviour):
Code:
tar xvfz file.tar.gz -C ./
edit: I misread the requirements; this method won't extract the contents of a directory, only the directory itself, if that is what's been tarred. To extract the contents, so long as you know the structure of the archive, you can specify files to extract manually:
Code:
tar xvfz file.tar.gz directory/contents/you/want/to/extract/
This will extract the contents of directory/contents/you/want/to/extract/.

Last edited by pwc101; 12-09-2008 at 05:37 AM.
 
Old 12-09-2008, 07:03 AM   #5
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by mitesh.ever View Post
Please let me know how to extracting .tar.gz files in current directory...without creating new directory, that it will create..automatically..

thanks!!
tar extracts files into current directory by default. When it creates directory, it happens because directory is stored in archive.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
move all files in current directory into a subdirectory in the current directory jakykong Linux - Newbie 8 07-17-2013 12:46 AM
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 12:02 PM
extracting tar.gzip files drmjh Linux - Newbie 6 08-15-2007 03:30 AM
Extracting a tar ball directly into a directory kushalkoolwal Debian 2 09-28-2005 02:47 PM
tar - extracting a single directory from a large archive? lowpro2k3 Linux - General 1 07-24-2005 03:44 AM

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

All times are GMT -5. The time now is 01:07 AM.

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