How to extract archive to a specified directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to extract archive to a specified directory
# 1  
Old 03-01-2004
Question How to extract archive to a specified directory

Hi,

I would like to extract the files from an archive which I have copied from a different server which has different file structures to my server.

When I do a tar xvf archive_name, I get the error saying the file or directory cannot be found. How do I specify a desginated directory to hold the files being extracted.

Thanks in advance.

John
# 2  
Old 03-01-2004
To extract to a specific directory (on Linux) try

tar xzf archive.tar.gz -C somedir/

somedir must exist.
# 3  
Old 03-01-2004
Thanks cbkihong,

I tried this:

tar xzf CDB20030623 -C /u06/keyforce/master/hist/

and I got this (I don't think it recognises the z parameter):

Usage: tar -{c|r|t|u|x} [-BdFhilmopsvw]
[-Number] [-fFile]
[-bBlocks] [-S [Feet] [Feet @Density] [Blocksb]]
[-LInputList] [-NBlocks] [-C Directory] File ...

then I tried this:

tar xvf CDB20030623 -C /u06/keyforce/master/hist/

No errors, but also no output either.

Thanks.
# 4  
Old 03-02-2004
Is your file b/gzipped? If not, i.e. just tar'red your command should work. Otherwise you need to gunzip it first, say

zcat gzipped_tar_file | tar xf - -C somedir/
# 5  
Old 03-02-2004
Thanks cbkihong,

The file is not zipped. However, I have been able to work around the problem by creating a file link to the "missing directory".

Thanks again for helping.

John
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Extract part of an archive to a different file

I need to save part of a file to a different one, start and end offset bytes are provided by two counters in long format. If the difference is big, how should I do it to prevent buffer overflow in java? (7 Replies)
Discussion started by: Tribe
7 Replies

2. UNIX for Dummies Questions & Answers

Extract tar archive on remote server in another directory

HI All Please suggest how to untar archive on remote sever. When im trying use regular command without any flags everything is working fine: $( ssh <user>@<server> -n '. ~/.profile >/dev/null 2>&1 ; cd /path_1 ; copiedIVR_name=`ls -tr | tail -1` ; tar xvf $copiedIVR_name ' ) but when im... (9 Replies)
Discussion started by: BACya
9 Replies

3. Shell Programming and Scripting

Extract tar archive on remote server in another directory

HI Please suggest how to untar archive on remote sever. When im trying use regular command without any flags everything working fine: $( ssh <user>@<server> -n '. ~/.profile >/dev/null 2>&1 ; cd /path_1 ; copiedIVR_name=`ls -tr | tail -1` ; tar xvf $copiedIVR_name ' ) but i have to ... (1 Reply)
Discussion started by: BACya
1 Replies

4. Shell Programming and Scripting

> dpkg-deb to Extract and Reconstruct a Multipart Archive???

Greetings! Here's one which has been bugging me for a bit ;) As might be known, LibreOffice is available to some of us Linux folk as a large set of debs. Of course, being a curious sort, I'd like to dig in and recreate the original tree which is composed of these assorted archives. So, I... (1 Reply)
Discussion started by: LinQ
1 Replies

5. UNIX for Dummies Questions & Answers

Extract directory name from the full directory path in UNIX using shell scripting

My input is as below : /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/loyal/IFIND.HELLO.WROC.txt /splunk/scrubbed/triumph/ifind.triumph.txt From the above input I want to extract the file names only . Basically I want to... (5 Replies)
Discussion started by: IshuGupta
5 Replies

6. Shell Programming and Scripting

How to use pkzipc to archive a directory

Hi, I want to know option that is used to archive a directory in zip. I have used the below command to achive the goal: pkzipc -add -deflate64 -silent -path=none abc.zip FXML.13062.XGC312011201001 But it is returning comment "Nothing to do!" (0 Replies)
Discussion started by: ezee
0 Replies

7. UNIX for Dummies Questions & Answers

Unable to restore cpio archive to a directory

Hello Every one, I want to back up all passwd files to /xyz/passfiles.cpio and Then restore them to /abc directory. Here is what I wrote: find / -name passwd | cpio -oc > /tmp/passwd.cpio and to restore cd abc cpio -ium < /tmp/passwd.cpio I can not find the files restored to /abc... (2 Replies)
Discussion started by: drdigital_m
2 Replies

8. Shell Programming and Scripting

moving log file into Archive directory

Hi All, I'm trying to write a script which will do following : - For any old log under trace directory, if found move it to Archive - Check for a process “process-A” if it is running abort from the script - Else start it up (start_process-A.sh this case) - If it fails to start the... (1 Reply)
Discussion started by: mohullah
1 Replies

9. Shell Programming and Scripting

Archive directory script with tar/compress

Hi all I need to write a script that archives all files with a certain date in the filename, to another location. It has to run on a AIX using tar/compress or another standard AIX tool. The directory will have x files, each prefixed with a date like yyyymmdd_desc.csv. I need all to... (7 Replies)
Discussion started by: AIXfrog
7 Replies

10. UNIX for Dummies Questions & Answers

choose what to extract from tar archive

Hello! I want to extract a choosen directory (and its contents) from a tar archive and i have tried what i believe is every option i could find in the manual. I think i have done it once before, but i don't remeber how. Could anyone please tell me how to do? (2 Replies)
Discussion started by: noratx
2 Replies
Login or Register to Ask a Question