HOW TO extract.tar file to specific directory..? | Unix Linux Forums | Solaris

  Go Back    


Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

HOW TO extract.tar file to specific directory..?

Solaris


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-30-2013
manalisharmabe manalisharmabe is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 13 June 2014, 4:26 AM EDT
Posts: 159
Thanks: 103
Thanked 2 Times in 2 Posts
HOW TO extract.tar file to specific directory..?

Hi all,

In Solaris howto extract tar file to specific folder.

This is what we do in Linux, but how to do the same thing in Solaris ?


Code:
-tar     -xzvf   /tmp/etc.tar.bz  -C /tmp

(Will extract in /tmp dir)


Code:
3.gzip COMPRESSION AND EXTRACTION
-tar     -czvf  /tmp/etc.tar.bz     /etc
-du           -csh   /tmp/etc.tar.bz   7.4M
-tar     -xzvf   /tmp/etc.tar.bz
-tar     -xzvf   /tmp/etc.tar.bz  -C /tmp

(Will extract in /tmp dir)

Last edited by Scott; 02-02-2013 at 10:34 AM.. Reason: Formatting
Sponsored Links
    #2  
Old 01-30-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 20 August 2014, 3:47 PM EDT
Location: Southern NJ, USA (Nord)
Posts: 4,398
Thanks: 8
Thanked 536 Times in 515 Posts
Usually, the tar has a relative path, which you can see in the t output. It will make the leading directory if any. So, run tar in the target directory where you want that subtree:
Code:
( cd somewhere ; tar xf - ) < whatever.tar

The Following User Says Thank You to DGPickett For This Useful Post:
manalisharmabe (02-03-2013)
Sponsored Links
    #3  
Old 02-02-2013
cjashu cjashu is offline
Registered User
 
Join Date: Feb 2012
Last Activity: 7 May 2014, 4:43 PM EDT
Posts: 114
Thanks: 51
Thanked 4 Times in 4 Posts
Lets say you want to tar testzone.tar in /zones directory


Code:
# mv testzone.tar /zones
# cd /zones 
verify that the file is in the /zones director
# ls
# tar xf testzone.tar
# ls


Last edited by Scott; 02-02-2013 at 10:34 AM.. Reason: Code tags
The Following User Says Thank You to cjashu For This Useful Post:
manalisharmabe (02-03-2013)
    #4  
Old 02-03-2013
manalisharmabe manalisharmabe is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 13 June 2014, 4:26 AM EDT
Posts: 159
Thanks: 103
Thanked 2 Times in 2 Posts
Hi cjashu

What you say is right but, if I need to write in script extract in particular directory then your method wont work.

May be what DGPickett said would work...
Sponsored Links
    #5  
Old 02-05-2013
MadeInGermany MadeInGermany is offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 21 August 2014, 6:59 PM EDT
Location: Simplicity
Posts: 1,841
Thanks: 117
Thanked 530 Times in 480 Posts
Unix tar does not have a built-in (de)compression.
The advantage is that the newest (de)compression methods can be used without updating the tar binary.
The disadvantage is that you must get used to complex shell code.
Example:

Code:
bunzip2 -c whatever.tar.bz2 | ( cd somewhere && tar xvf - )

The && is safer than the semicolon.
Sponsored Links
    #6  
Old 02-07-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 20 August 2014, 3:47 PM EDT
Location: Southern NJ, USA (Nord)
Posts: 4,398
Thanks: 8
Thanked 536 Times in 515 Posts
Yes, more generally, just decompress stdin:
Code:
any_appropriate_decompress_tool <yours.some_comp_tar_ext | ( cd somewhere && tar xvf - )

gunzip or gzcat for .tgz, .tar.gz and .tar.Z,
uncompress for tar.Z,
bunzip2 for .tbz or .tar.bz2

Pipes are neat for moving stuff through rsh/ssh to another host without making a local copy of the compressed file.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
extract tar.gz under a specific folder melanie_pfefer Solaris 3 02-24-2009 09:20 AM
tar extract to different directory ammu UNIX for Advanced & Expert Users 1 07-25-2007 10:54 AM
extract tar files without creating directory here2learn UNIX for Dummies Questions & Answers 4 10-02-2006 07:42 PM
extract a sub directory form a tar file Optimus_P UNIX for Advanced & Expert Users 2 01-28-2004 12:23 PM
redirecting tar extract to another directory colesy UNIX for Dummies Questions & Answers 7 01-28-2003 03:40 AM



All times are GMT -4. The time now is 01:54 AM.