Unix/Linux Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

tar extract to different directory

UNIX for Advanced & Expert Users


Tags
tar extract, tar extract directory, tar extract to directory

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-25-2007
ammu ammu is offline
Registered User
 
Join Date: Jul 2006
Last Activity: 26 August 2010, 9:37 AM EDT
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
tar extract to different directory

Hi,

I created a tar file of a directory dir1 from /tmp in the following way

$pwd
/tmp
$tar -cvf dir1.tar dir1 (dir1 will have say file1)

Now i want to extract it in the directory /tmp/dir2 so that the directory dir1 is also created and extracted (/tmp/dir2/dir1/file1). Is there any way without creating the directory first(dir1) the dir1 can be extracted?

Thanks in advance
Ammu
Sponsored Links
    #2  
Old Unix and Linux 07-25-2007
vgersh99's Unix or Linux Image
vgersh99 vgersh99 is offline Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 6 July 2015, 4:18 AM EDT
Location: Foxborough, MA
Posts: 7,825
Thanks: 174
Thanked 653 Times in 610 Posts

Code:
(cd /tmp; tar cf - dir1) | (cd /tmp/dir2; tar xf - )

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Loop through directory and extract sub directory names personalt UNIX for Dummies Questions & Answers 1 08-29-2011 12:13 PM
How to extract contents of ONLY one directory from ZIP folder. Sheel UNIX for Dummies Questions & Answers 2 03-04-2011 07:24 AM
Extract directory from a file path mrudula009 Shell Programming and Scripting 4 06-10-2009 01:48 AM
How to extract archive to a specified directory john_trinh UNIX for Dummies Questions & Answers 4 03-02-2004 05:07 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 05:14 AM.